JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 10th, 2001, 03:21 AM
hopsakee hopsakee is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 29 hopsakee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Javascript problem

Hi!

I want to get the status (true or false) of a checkbox with Javascript. Normally, I use "document.myform.mycheckbox.checked", but in this case, "mycheckbox" is an array.

"document.myform.mycheckbox[0].checked" doesn't work.
"document.myform.mycheckbox[].checked" doesn't work.
"document.myform.mycheckbox.0.checked" doesn't work...

Who knows the answer?

Thanks!

Reply With Quote
  #2  
Old October 10th, 2001, 04:36 AM
liljim's Avatar
liljim liljim is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: England
Posts: 967 liljim User rank is Lance Corporal (50 - 100 Reputation Level)liljim User rank is Lance Corporal (50 - 100 Reputation Level)liljim User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 20 h 32 m 5 sec
Reputation Power: 12
Something like this?

function ValidateCheckBoxes() {

var checkered_flag = 0;

for (var i = 0; i < 10; i++) {
if (document.myform.elements["checkboxname[" + i + "]"].checked == true) {
checkered_flag++;
}
}

if (checkered_flag == 0) {
return false;
}
return true;
}

would loop through an array of checkboxes called "checkboxname[0]" to "checkboxname[9]" in a form called "myform" - if one or more of the checkboxes is checked, the function returns true. Be more specific if this wasn't what you wanted the function to do...

Reply With Quote
  #3  
Old October 10th, 2001, 05:42 PM
hopsakee hopsakee is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 29 hopsakee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I didn't need the function you described, but you helped me great with this part of your reply:

Quote:
document.myform.elements["checkboxname[" + i + "]"].checked


Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Javascript problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap