Example
The code is as follows |
Copy Code |
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <title>jquery $.ajax $.post or $.get How to submit a checkbox value </title> <script type= "Text/javascript" src= "/js/jquery.min.js";></script> <script type= "Text/javascript" > function SubmitForm () { var str= '; $ ("#phpernote >[type=checkbox]"). each (function () { if ($ (this) [0].checked) { str+=$ (This). Val () + ', '; } }); alert (str); } </script> <body> <form id= "Phpernote" action= "Javascript:submitform ();" method= "POST" > <input type= "checkbox" value= "1"/>1<br/> <input type= "checkbox" value= "2"/>2<br/> <input type= "checkbox" value= "3"/>3<br/> <input type= "checkbox" value= "4"/>4<br/> <input type= "checkbox" value= "5"/>5<br/> <input type= "Submit" value= "submitted"/> </form> </body> |
The idea is simply to take the selected values out, loop them into strings, and pass them out.