tinfanide Posted October 31, 2011 Share Posted October 31, 2011 <html><head><script>function parseXML(method,xml,async){if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); xmlhttp.open(method,xml,async); xmlhttp.send(); }else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") ; xmlhttp.async=async; xmlhttp.load(xml); }xmlDoc = xmlhttp.responseXML;}parseXML("GET","multipleChoices.xml",false);function test(){if(document.getElementById("c1").checked == true){ alert(1); } else { alert(2); }}</script></head><body><form name="form"><fieldset> <input type="radio" id="c1" value="a" name="a" />a <input type="radio" id="c2" value="b" name="b" />b <input type="radio" id="c3" value="c" name="c" />c <input type="radio" id="c4" value="d" name="d" />d </fieldset> <input type="button" value="submit" onClick="test()" /></form></body></html> Radio buttons should only be unique. Only one option is allowed to select. But in my case, more than one radio button are allowed to be clicked.Why? And how to fix it? Link to comment Share on other sites More sharing options...
eTianbun Posted October 31, 2011 Share Posted October 31, 2011 All radio buttons, in the same category, should have the same name. Ex:colors: ()red()blue()green. given the above radios, all the radios should have the same name, which means that they are under colors (the same category), and one should be selected and not all. Link to comment Share on other sites More sharing options...
Ingolme Posted October 31, 2011 Share Posted October 31, 2011 If you give all the radio buttons the same "name" attribute then only one of them can be selected. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.