Hi guys.
I would really appreciate some help with this as I cant for the life of me get it to work.
I have a series of checboxes created in a php script. The name of the checboxes is weeks[]. This creates an array when the different weeks are seelected so I can input all the weeks that are checked into a DB.
However, just to make things easier I want to create a button that checks and unchecks all the checboxes to make things easier. I have tried adding some javascript but I don't think it likes it when I use an array as the checkbox name. Does anyone know how I can do this while maintaining the array?
thanks alot
PHP/JS check all, uncheck all button for checkboxes
Moderator: General Moderators
-
ant_sutton
- Forum Commoner
- Posts: 32
- Joined: Thu May 05, 2005 5:27 am
-
ant_sutton
- Forum Commoner
- Posts: 32
- Joined: Thu May 05, 2005 5:27 am
re
Thanks for your reply feyd. Not really sure how to use that code though:)
here is what I'm trying to use so far
thanks
Anthony
here is what I'm trying to use so far
Code: Select all
<SCRIPT LANGUAGE="JavaScript">
<!--
<!-- Begin
function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}
function UnCheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
// End -->
</script>
<form name="myform" action="makerequest2.php" method="post">
Weeks:<input type="checkbox" name="weeks[]" value="1">week1<br>
<input type="checkbox" name="weeks[]" value="2">week2<br>
<input type="checkbox" name="weeks[]" value="3">week3<br>
<input type="checkbox" name="weeks[]" value="4">week4<br>
<input type="checkbox" name="weeks[]" value="5">week5<br>
<input type="button" name="Check_All" value="Check All"
onClick="CheckAll(document.myform.check_list)">
<input type="button" name="Un_CheckAll" value="Uncheck All"
onClick="UnCheckAll(document.myform.check_list)"> <br />Anthony
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England