Jump to content

Strange Html Radio Button: Only One Feature Disabled


tinfanide
 Share

Recommended Posts

<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?

  • Like 1
Link to comment
Share on other sites

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.

Edited by eTianbun
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...