javascript - Check status of all checkboxes in a form -
i have several check box in form wanna way check whether checked or not .
if checked need store id in database(that can ) . question how determine whether checked or not instead of checking each check box on @ time .
this code
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body> role id<input type="text" name="roll_id"/><br> role name<input type="text" name="roll_name"/><br> role description<textarea name="roll_desc"></textarea><br> <br> <br> screen1<br> tab1<br> <input type="checkbox" name="s1_t1_view" value="s1_t1_view" >view<br> <input type="checkbox" name="s1_t1_add" value="s1_t1_add" >add<br> <input type="checkbox" name="s1_t1_edit" value="s1_t1_edit" >edit<br> <input type="checkbox" name="s1_t1_delete" value="s1_t1_delete" >delete<br> tab2<br> <input type="checkbox" name="s1_t2_view" value="s1_t2_view" >view<br> <input type="checkbox" name="s1_t2_add" value="s1_t2_add" >add<br> <input type="checkbox" name="s1_t2_edit" value="s1_t2_edit" >edit<br> <input type="checkbox" name="s1_t2_delete" value="s1_t2_delete" >delete<br> screen2<br> tab1<br> <input type="checkbox" name="s2_t1_view" value="s2_t1_view" >view<br> <input type="checkbox" name="s2_t1_add" value="s2_t1_add" >add<br> <input type="checkbox" name="s2_t1_edit" value="s2_t1_edit" >edit<br> <input type="checkbox" name="s2_t1_delete" value="s2_t1_delete" >delete<br> tab2<br> <input type="checkbox" name="s2_t2_view" value="s2_t2_view" >view<br> <input type="checkbox" name="s2_t2_add" value="s2_t2_add" >add<br> <input type="checkbox" name="s2_t2_edit" value="s2_t2_edit" >edit<br> <input type="checkbox" name="s2_t2_delete" value="s2_t2_delete" >delete<br> <input type="submit" name="sumbit" text="submit"> </body> </html>
you can use each
:
$("input[type=checkbox]").each(function() { var elem = $(this); if (elem.is(":checked")) { // item checked } })
Comments
Post a Comment