|
 |
|
Dev Articles Community Forums
> Programming
> JavaScript Development
|
"Check All" checkbox - works, but, it doesn't let me post the form
Discuss "Check All" checkbox - works, but, it doesn't let me post the form in the JavaScript Development forum on Dev Articles. "Check All" checkbox - works, but, it doesn't let me post the form JavaScript Development forum discussing the use of JavaScript and its features as a powerful DOM manipulator. JavaScript is used in most websites to enrich the interface and enhance the user experience.
|
|
 |
|
|
|

Dev Articles Community Forums Sponsor:
|
|

July 16th, 2004, 05:11 AM
|
Registered User
|
|
Join Date: May 2004
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
"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>
|

July 16th, 2004, 06:24 AM
|
 |
Contributing User
|
|
Join Date: May 2003
Location: Tennessee
Posts: 1,355
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
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.
|

July 16th, 2004, 06:29 AM
|
Registered User
|
|
Join Date: May 2004
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
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 07:20 AM.
Reason: Place code in code tags - I've combined the code from your first post
|

July 16th, 2004, 10:14 AM
|
 |
Contributing User
|
|
Join Date: May 2003
Location: Tennessee
Posts: 1,355
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
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.
|

July 16th, 2004, 10:34 AM
|
 |
May contain nuts.
|
|
Join Date: Aug 2002
Posts: 2,056
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
|
|
Why is there a anchor (<a>) around the check box? That can't be helping.
|
Developer Shed Advertisers and Affiliates
Thread Tools |
Search this Thread |
|
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|