Connecting Tech Pros Worldwide Forums | Help | Site Map

Automatically uncheck check/uncheck button on unchecking one selection

kid kid is offline
Newbie
 
Join Date: Jul 2007
Posts: 13
#1: Jul 30 '07
Hi,
I have 5 checkbox elements,
i.e:

( 1 ) a
( 2 ) b
( 3 ) c
( 4 ) d
( Check/Uncheck all )

i want to check all the selections if the check button is check and uncheck all the selections when the uncheck button is unchecked but here's the catch, if i uncheck the 1st selection or other selections the check/uncheck button will automatically uncheck too. can anyone help me please?

gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#2: Jul 30 '07

re: Automatically uncheck check/uncheck button on unchecking one selection


hi ...

please post the code you already have, the check- and uncheck-controls are checkboxes too? ... please show the html too ...

kind regards
kid kid is offline
Newbie
 
Join Date: Jul 2007
Posts: 13
#3: Jul 30 '07

re: Automatically uncheck check/uncheck button on unchecking one selection


heres my code:

[HTML]<form name="myform" action="myform.php" method="post">
<b>Your Favorites</b><br>
<input type="checkbox" name="list" value="1">Pie<br>
<input type="checkbox" name="list" value="2">Pizza<br>
<input type="checkbox" name="list" value="3">Candy<br>
<input type="checkbox" name="list" value="4">Soda<br>
<input type="checkbox" name="list" value="5">Antacids<br>

<input type="checkbox" name="listAllCheck" value="listAllCheck" onClick="checkAll(document.myform.list,this)"><str ong>Check / Uncheck All</strong><br>
</form>


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkAll(checkname, checksubmit) {
for (i = 0; i < checkname.length; i++)
checkname[i].checked = checksubmit.checked? true:false
}
// End -->
</script>[/HTML]
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#4: Jul 30 '07

re: Automatically uncheck check/uncheck button on unchecking one selection


hmmm ... ok ... but i don't get the problem. you check the check-all checkbox and all checkboxes will be checked, uncheck it ... unchecks all boxes ... and now? when checking/unchecking a box from the list - nothing happens, so what behaviour do you want to have?

kind regards
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Jul 31 '07

re: Automatically uncheck check/uncheck button on unchecking one selection


Changed the thread title.

Please use meaningful titles. Thank you.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Jul 31 '07

re: Automatically uncheck check/uncheck button on unchecking one selection


Quote:

Originally Posted by kid

Hi,
I have 5 checkbox elements,
i.e:

( 1 ) a
( 2 ) b
( 3 ) c
( 4 ) d
( Check/Uncheck all )

i want to check all the selections if the check button is check and uncheck all the selections when the uncheck button is unchecked but here's the catch, if i uncheck the 1st selection or other selections the check/uncheck button will automatically uncheck too. can anyone help me please?

I think this link will help.
Reply