I am trying to select all the checkbox values on one click, I used the same thing in another project a few months ago , Where it's working fine, but now it's not working, I'm giving you my complete code, this code is: ....
& lt; Tbody & gt; & Lt; Span style = "margin-left: 0px;" & Gt; Select All & amp; Nbsp; & Lt; Input type = "checkbox" name = "foo" onClick = "checkall (this)" & gt; & Amp; Nbsp; & Amp; Nbsp; & Lt; Input type = "submit" value = "delete" name = "delete" & gt; ; & Lt; / Span & gt; & Lt ;? Php if ($ allTemplates> 0): $ sr = '1'; While ($ line = mysql_fetch_array ($ allTemplates)):? & Gt; & Lt; TR & gt; & Lt; Td class = "text-center" & gt; Input type = "checkbox" name = "foo []" value = "& lt ;? php echo $ row ['id'];? & Gt;" / & Gt; & Lt ;? Php echo $ sr; ? & Gt; & Lt; / TD & gt; & Lt; Td class = "hidden-phone" style = 'text-align: center;' & Gt; & Lt ;? Php echo $ row ['on_date']; ? & Gt; & Lt; / TD & gt; & Lt; Td class = "hidden-phone" style = 'text-align: center;' & Gt; & Lt; A href = "javascript: showing ('# .php? Id = & lt;; echo $ line [' template_id ']? & Gt;')" & gt; & Lt ;? PHP resonance $ line ['template_id']; ? & Gt; & Lt; / A & gt; & Lt; / TD & gt; & Lt; Td class = "hidden-phone" & gt; & Lt ;? Php Echo ucfirst ($ line ['title']); ? & Gt; & Lt; / TD & gt; & Lt; Td class = "hidden-phone" style = 'text-align: center;' & Gt; & Lt; A href = "javascript: showing ('profile_lady.php? Id = & lt ;; echo $ row [' user_id ']? & Gt;')" & gt; & Lt ;? Php echo $ line ['user_id']; ? & Gt; & Lt; / A & gt; & Lt; / TD & gt; & Lt; Td class = "hidden-phone" style = 'text-align: center;' & Gt; & Lt ;? Php echo ucfirst ($ record ['fname']) '' $ Record ['lname']; ? & Gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php $ sr ++; Endwhile; end if; ? & Gt; & Lt; / Tbody & gt;
And the function I used here is ...
& lt; Script language = "javascript" & gt; Function checkol (source) {checkbox = document.getElementsByName ('foo []'); (Var i = 0, n = checkbox length; i & lt; n; i ++) {checkbox [i]. Checkeded = source.checked; }} & Lt; / Script & gt;
If you have any solutions please help me ....
Try it
var elems = document.getElementsByTagName (" Input "); (Var i = 0; i & lt; elems.length; i ++) {if (ames [i]. Type == 'checkbox') ames [i]. Checked = true; }
Comments
Post a Comment