This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

checkbox code php

By: a guest on Mar 23rd, 2012  |  syntax: None  |  size: 0.86 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ////Code for obtaining and displaying Checkbox list
  2. <div id="exxx">
  3. <fieldset><legend>Select Export Fields</legend>
  4. <?php
  5. $result=mysql_query("desc student_test",$conn);
  6. echo '<ul id="unshund">';
  7. while($row=mysql_fetch_array($result))
  8. {
  9. $val=$row['Field'];
  10. ?>
  11. <script language="JavaScript">
  12. $(function(){
  13. $("#chkAll").change(function(){
  14. if (this.checked == true) {
  15. $("input:checkbox.child").attr("checked", "checked");
  16. }
  17. else {
  18. $("input:checkbox.child").removeAttr("checked");
  19. }
  20. });
  21. });
  22. </script>
  23.  
  24. <li ><input type='checkbox' class="child" name='' id=<?php echo $val; ?> value=<?php echo $val; ?> onchange="javascript:selectedField(this.id)" <?php if(isset($_SESSION['selectedFields'][$val])) { echo 'checked="checked"';} ?> /> <?php echo ucfirst($row['Field']);?> </li>
  25. <?php
  26. }
  27. echo '</ul>';
  28. ?>
  29. <input type="checkbox" id="chkAll" /> Toggle All<br/>
clone this paste RAW Paste Data