treeleaf20
12-03-2009, 02:47 PM
All,
I have the following checkbox code:
echo "<input name=\"picbigid[]\" type=\"checkbox\" value=\"$pic[src_big]\">";
I then want to select all the checkboxes so I have this code:
echo "<input type=\"button\" name=\"CheckAll\" value=\"Check All\" onClick=\"checkAll(document.photos.picbigid)\"> <input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\" onClick=\"uncheckAll(document.photos.picbigid)\">";
[PHP]
My JS function is:
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
If I do it like this:
[PHP]
echo "<input name=\"picbigid\" type=\"checkbox\" value=\"$pic[src_big]\">";
It works but I can't have it like that because the form posts to another PHP page that needs the input name as an array.
Any ideas?
Thanks!
I have the following checkbox code:
echo "<input name=\"picbigid[]\" type=\"checkbox\" value=\"$pic[src_big]\">";
I then want to select all the checkboxes so I have this code:
echo "<input type=\"button\" name=\"CheckAll\" value=\"Check All\" onClick=\"checkAll(document.photos.picbigid)\"> <input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\" onClick=\"uncheckAll(document.photos.picbigid)\">";
[PHP]
My JS function is:
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
If I do it like this:
[PHP]
echo "<input name=\"picbigid\" type=\"checkbox\" value=\"$pic[src_big]\">";
It works but I can't have it like that because the form posts to another PHP page that needs the input name as an array.
Any ideas?
Thanks!