i have a problem

W

wyrd_fish

Guest
in a PHP script of mine, i need to be able to select a load of check boxes, and use this to delete some rows from a table

simple you'd think, I can't think of a way to do it without 40 if statments

please help
 
F

FatBusinessman

Guest
First thought: assign the true/false values from the checkboxes to an array. Then you can simply traverse through that array, deleting the appropriate records whenever you have a true value.
 
S

(Shovel)

Guest
Is this selecting a load of them at once?

What you need is a JavaScript DOM function. I don't know the exact functions you'd use, it would go something like this:

Firstly, all of the checkboxes involved, need to be assigned a class (e.g class="selectall").

Then, a JavaScript function that follows this logic:
Code:
function selectAll() {
 if (!document.getElementsByClass) return;

 var checkboxes = document.getElementsByClass("selectall");
 for (var i=0; i<checkboxes.length; i++) {
     checkboxes[i].checked = true;
 }
}

Now, there's a fair bit of that that may be named wrong - you'll need to look up the "checkbox.checked" property and find out what it is actually called. I believe that "getElementsByClass()" is correct.

You then want a button that says "Select All", with an onClick action of "selectAll()".

I am only this DOM business myself, but it's fairly easy to pick up, and I belive that that is how you would go about it. It's very powerful stuff.
 
W

wyrd_fish

Guest
no not selecting everything...

how do you assign values to an array without explode(); ???

do you just name the variable $whatever[moo] or what???

doh... just thought of using a for loop!!!
 

Users who are viewing this thread

Similar threads

M
Replies
9
Views
975
Krazeh
K
R
Replies
8
Views
481
W
W
Replies
4
Views
752
evilmonkeh
E
Top Bottom