PHP/java Script select all button

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

PHP/java Script select all button

Post by pinehead18 »

Ok this is a bit complicated i hope i explain it correctly.

I have a news letter script, i have a place where you can manually select (with a check box) the people you want to send to. <input type=checkbox name=users[]>

I'm using users[] because it adds it to an arrray and i can send to everyone in the array.

function checkAll(field)
{
for (i = 0; i < field.length; i++)
field.checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field.checked = false ;
}

Is my java script

<input type="button" class="submit" name="CheckAll" value="Check All" onClick="checkAll(document.myform.users)">


is my submit javascript


<tr bgcolor=#eeeeee><td><input type=checkbox name=\"users\" value=$email></td><td>$lastname</a></td><td>$firstname</td><td>$email</td><td>$birthday</td>

Is my check box.


when i have name=users it works great.

But when i have name=users[] and i add users[] to the top from just users it doesn't.

How can i do this and still have the array? Do i need to do something witht he php code or do i need to change something in the javascript.

if so what?

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Properly reference the element.

document.forms['formName'].elements['elementName']
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

or try document.getElementById().

see http://www.w3.org/TR/REC-DOM-Level-1/le ... D-36113835
Post Reply