Current location: Hot Scripts Forums » General Web Coding » JavaScript » checkbox.length problem


checkbox.length problem

Reply
  #1 (permalink)  
Old 06-24-03, 05:00 PM
Hawaii 5-0 Hawaii 5-0 is offline
New Member
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question checkbox.length problem

Here is a snippet of the code I am using:

Code:
var docLength = eval("document.Lineup." + ck + ".length");
for (counter = 0; counter < docLength; counter++) {
I have quite a few different checkboxes (I have a form to submit a fantasy football team) and each group is named by a 2 letter position type - QB, RB, WR, TE, etc.

My problem is if there is only 1 checkbox in the group (I have only 1 TE) then docLength is returned "undefined". I have tried testing the value of docLength and changing it to 1 if it is undefined, but for some reason my form just submits even if the rest of the fields aren't validated yet.

I hope this is fairly clear. Please let me know if you need anymore code. Any help would be greatly appreciated!
Reply With Quote
  #2 (permalink)  
Old 06-24-03, 05:37 PM
Hawaii 5-0 Hawaii 5-0 is offline
New Member
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Just an update:

I have tried making this modification, but it still just exits the form.

Code:
	var docLength = eval("document.Lineup." + ck + ".length");
	if (typeof docLength == 'undefined') {
		if (eval("document.Lineup." + ck + "[0].checked")) {
			ck_choices = 1;
		}
	} else {
		for (counter = 0; counter < docLength; counter++) {

Last edited by Hawaii 5-0; 06-24-03 at 05:43 PM.
Reply With Quote
  #3 (permalink)  
Old 06-24-03, 06:03 PM
Hawaii 5-0 Hawaii 5-0 is offline
New Member
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Well a little trial and error and a whole lot of persistence paid off. I figured it out! Here is the change, if any are interested:

Code:
if (eval("document.Lineup." + ck + ".checked")) {
Thanks anyway, all...
Reply With Quote
  #4 (permalink)  
Old 11-27-03, 02:15 PM
Seran Seran is offline
New Member
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
thx mate

You just saved me hours of playing around with more javascript commands then you can probably imagine

thank you!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with textarea skchakri ASP 1 10-08-03 09:16 AM
file download problem ukyankee Perl 6 10-04-03 10:39 PM
jpGraph axis labeling problem Squeezer PHP 2 08-20-03 07:53 AM
new problem libr JavaScript 3 08-11-03 06:25 AM


All times are GMT -5. The time now is 11:46 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.