|
Help.
Nov 10, 2005 9:10:54 GMT -8
Post by egbakaet on Nov 10, 2005 9:10:54 GMT -8
I have this script which allows me to select all checkboxes from a list of checkboxes that are going to be deleted from a mysql database with the name of list[]. var formblock; var forminputs;
function prepare() { formblock= document.getElementById('dnews'); forminputs = formblock.getElementsByTagName('input'); }
function select_all(name, value) { for (i = 0; i < forminputs.length; i++) { // regex here to check name attribute var regex = new RegExp(name, "i"); if (regex.test(forminputs.getAttribute('name'))) { if (value == '1') { forminputs.checked = true; } else { forminputs.checked = false; } } } }
if (window.addEventListener) { window.addEventListener("load", prepare, false); } else if (window.attachEvent) { window.attachEvent("onload", prepare) } else if (document.getElementById) { window.onload = prepare; }
The problem is, for the one form with the id="dnews" and name="dnews", I get no errors. But since I'm using an admin panel with everything in one file, when I go to another part with another form called say id="addnews", I get an error saying formblock is null or not an object on any other form but the dnews form. Can anyone help me fix this? Thanks
|
|
|
Help.
Nov 10, 2005 19:03:38 GMT -8
Post by CD on Nov 10, 2005 19:03:38 GMT -8
Well, if you only select the form "dnews", there's your problem. Try changing it depending on the page.
|
|