coder coder -4 years ago 98
HTML Question

radio boxes are not setting attribute checked

I guess kind of a silly question here. I have created a .html file on my desktop outside of fiddle (so please don't test it in fiddle but just create a .html file on your computer to test this). in the file I JUST have 3 radio buttons and jquery attached. However, boxes never work right as checked or clicked attribute never gets set on them and literally they don't alternate when checked on. What am I missing here?

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
</head>
<body>
<input type="radio" name="well" value="well" />1 - Very well<br />
<input type="radio" name="little" value="little" />2 - A little<br />
<input type="radio" name="not" value="not" />3 - Not at all<br />
</body>



Answer Source

Your radio buttons don't know they're related. The name attribute should be the same, while the value can be changed for each.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="radio" name="rating" value="well" />1 - Very well<br />
    <input type="radio" name="rating" value="little" />2 - A little<br />
    <input type="radio" name="rating" value="not" />3 - Not at all<br />

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download