Tip: you can modify some code before running
Javascript checks whether radio is selected<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Javascript checks whether radio is selected</title></head><body><form id="f" name="f" method="post" action=""> <p> <label> <input type="radio" name="RadioGroup1" value="a" />Single choice</label> <br /> <label> <input type="radio" name="RadioGroup1" value="b" />Single choice</label> <br /> <label> <input type="radio" name="RadioGroup1" value="c" />Single choice</label> <br /> <label> <input type="radio" name="RadioGroup1" value="d" />Single choice</label> <br /> </p> <label> <input type="submit" name="Submit" value="检测radio是否选中" onclick="checkradiobyvalue('RadioGroup1','d');" /> </label></form><script language="javascript">Function checkradiobyvalue (c, v) {if (! Undefined (c. item) {for (var I = 0; I <c. item. length; I ++) {if (c. item (I ). value = v) {c. item (I ). checked = true; break ;}}}}</script></body></html>
Tip: you can modify some code before running