A method for judging checkbox and radio-form effects

Source: Internet
Author: User
<ptml> <pead> <title> Judge checkbox and radio-51windows.net</title> <meta http-equiv= " Content-type "content=" text/html; charset=gb2312 "> </pead> <body> <form method=" POST "name=" myformname1 "> <input type=" checkbox "Name=" checkname1 "id=" C11 "value=" "><label for=" C11 "> select 1</label> <input type=" checkbox "Name=" Checkname1 "id=" C12 "value=" "><label for=" C12 "> select 2</label> <input type=" checkbox "Name=" checkname1 "Id=" C13 "value=" "><label for=" C13 "> select 3</label> <input type=" checkbox "Name=" checkname1 "id=" C14 " Value= "" ><label for= "C14" > select 4</label> <input type= "button" onclick= "Alert ischecked ( document.myformname1, ' checkname1 ') the "value=" test has chosen "> <input type=" button "onclick=" Alert Getcheckednum ( document.myformname1, ' checkname1 ') "value=" test select several "> </form> <pr> <form method=" POST "Name=" Myformname2 "> <input type=" Radio "Name=" RAdioname1 "id=" R11 "value=" "><label for=" R11 "> select 1</label> <input type=" Radio "name=" Radioname1 "id= "R12" value= "><label for=" R12 "> select 2</label> <input" button "type=" Alert onclick= ( Document.myformname2, ' radioname1 ') "value=" Test has no choice "> <input type=" reset "value=" reset "> </form> < SCRIPT language= "JavaScript" > <!--function ischecked (oform,checkname) {var len = oform.elements.length; var i=0; For (i=0 i<len; i++) {if (oform.elements[i].name==checkname) {if (oform.elements[i].checked) { return true; }} return false; function Getcheckednum (oform,checkname) {var len = oform.elements.length; var i=0; var checkn = 0; For (i=0 i<len; i++) {if (oform.elements[i].name==checkname) {if (oform.elements[i].checked) { checkn++; }} returnCheckn; }//--> </SCRIPT> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.