|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
"Check All" checkbox - works, but, it doesn't let me post the form
I have this form with lots of 'checkboxes'.
It worked fine until I implemented the javascript to 'check All'. when the user clicks on the top checkbox, it selects all the checkboxes in the list. And it works fine (it does select all the checkboxes when is checked or unselects when is unchecked). However, since I've done this, the form is not posted anymore! It doesn't go anywhere... I've tried using some other code with different ways, but, my JS is far too basic to understand what is really going on... this is the code - thank you! <script language="javascript"> function checkAll(allbox) { for (var i = 0; i < document.territory["Country_ID"].length; i++) { document.territory["Country_ID"][i].checked = allbox.checked; } } </script> It's implemented here: <form name="territory" method="GET" action="territory_country.asp" id="Form1"> <table border="0" cellpadding="5" cellspacing="1" align="center" width="100%"> <tr bgcolor="EEEEEE"> <td colspan="2"> <div class="popUp2"><a href="javascript:void();"><input type="checkbox" name="all" onClick="checkAll(this);">Select All</a></div> </td> </tr> |
|
#2
|
||||
|
||||
|
I presume you've got a submit button and you've closed your form tag?
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Yes... but, if the checkbox is clicked submit doesn't work
Sure. That's the end of my code: (I can post the whole page if it helps)
Code:
<script language="javascript">
function checkAll(allbox) {
for (var i = 0; i < document.territory["Country_ID"].length; i++) {
document.territory["Country_ID"][i].checked = allbox.checked;
}
}
</script>
<form name="territory" method="GET" action="territory_country.asp" id="Form1">
<div class="popUp2"><a href="javascript:void();"><input type="checkbox" name="all" onClick="checkAll(this);">Select All</a></div>
<input type="submit" name="Submit" value="Submit" id="Submit1">
<input type="hidden" value="<%=territory_ID%>" name="ID">
<input type="hidden" value="-1" name="submitted" id="Hidden1">
</form>
When i click on submit button, it doesn't do anything (If check all is clicked). If check all is not clicked then, it works fine and it submits the form. Thanks!! Last edited by stumpy : July 16th, 2004 at 08:20 AM. Reason: Place code in code tags - I've combined the code from your first post |
|
#4
|
||||
|
||||
|
Your script makes a reference to the form field "Country_ID," which doesn't exist. Also, I get an error on javascript:void() unless I pass "0" as a parameter. For js debugging, I suggest downloading Mozilla and using the js console to see errors.
|
|
#5
|
||||
|
||||
|
Why is there a anchor (<a>) around the check box? That can't be helping.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > "Check All" checkbox - works, but, it doesn't let me post the form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|