Posted By

krisdb on 05/30/07


Tagged

javascript


Versions (?)

check/uncheck and change bgcolor


 / Published in: JavaScript
 

  1. //checks all checkboxes and changes the background color
  2. function checkAllChangeBg(field,id,color1,color2) {
  3. if (!(field.length)) {
  4. field.checked = true;
  5. toggleBgcolor(id+'0',color1,color2);
  6. }
  7. else {
  8. for (var i = 0; i < field.length; i++) {
  9. field[i].checked = true;
  10. toggleBgcolor(id+i,color1,color2);
  11. }
  12. }
  13. }
  14.  
  15. //unchecks all checkboxes and changes the background
  16. function uncheckAllChangeBg(field,id,color1,color2) {
  17. if (!(field.length)) {
  18. field.checked = false;
  19. toggleBgcolor(id+'0',color1,color2);
  20. }
  21. else {
  22. for (var i = 0; i < field.length; i++) {
  23. field[i].checked = false;
  24. toggleBgcolor(id+i,color1,color2);
  25. }
  26. }
  27. }
  28. response.write "<a href=""javascript:checkAllChangeBg(document.CHECKBOX_FORM.FIELD,'idToChangeBg_','rgb(220, 237, 255)','rgb(255, 255, 255)');"">select</a> / "
  29.  
  30. response.write "<a href=""javascript:uncheckAllChangeBg(document.CHECKBOX_FORM.FIELD,'idToChangeBg_','rgb(255, 255, 255)','rgb(255, 255, 255)');"">deselect</a> all"

Report this snippet  

You need to login to post a comment.