In fact, the value of JS to get Radio is very simple, if it is a radio button group to traverse the line, if the radio is directly judged. Value on the line.
<!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= "HTML; charset=gb2312 "/> <TITLE>JS Get Radio Value </title> <script> function Radiogroup () {
for (var i=0;i<formobj.a.length;i++) { if (formobj.a[i].checked) { Alert ("Select box selected:" + formobj.a[i].value); return true; } } alert ("Unchecked"); return false; } </script> Instance two
<script> function Search (obj) { var Urlparam For (I=0;i<obj.getelementsbytagname ("input"). length-1;i++) { if (Obj.getelementsbytagname ("input") [i].checked) { Urlparam=obj.getelementsbytagname ("input") [I].value Break } } obj.action+= "&sjprice=" +urlparam return True } </script>
Function foo () { var selectedindex =-1; var Form1 = document.getElementById ("Form1"); var i = 0;
for (i=0 i<form1.gender.length; i++) { if (form1.gender[i].checked) { selectedindex = i; alert ("The value of your selected item is:" + form1.gender[i].value); break; } }
if (SelectedIndex < 0) { alert ("You have not selected any items"); } } </script> <bodY> <form method= "POST" <table> <tr><td> <input type = "Radio" value= "new"/> employee <input type= "Radio" value= "old" checked = "Checked"/> old employee <input type= "text"/> </td> < /tr> </table> </form>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.