473,508 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check All checkboxes for only one group of checkboxes

1 New Member
I found a Javascript snippet that very effectively checks all boxes on a page, even on a page on which the input tags are in tables and on which I use a lot of other javascript. Unfortunately it is too effective and checks all boxes in all groups of checkboxes - even disabled checkboxes.

I need a work-around (or new code) that will limit it to only check one group of boxes, perhaps by using a unique id for the input tag. (I tried adding
Expand|Select|Wrap|Line Numbers
  1.  && x.form[i].id='formid' 
where formid was the id of the input tag but it didn't work.


My input tag's names are in an array ( cs[1], cs[2], cs[3]. . . . ). I use PHP.

Can anyone help me?

The code I tried is :

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function selectAll(x) {
  3. for(var i=0,l=x.form.length; i<l; i++)
  4. if(x.form[i].type == 'checkbox' && x.form[i].name != 'sAll')
  5. x.form[i].checked=x.form[i].checked?false:true
  6. }
  7. </script>
  8.  
  9. <input type=\"checkbox\" name=\"SalleSalle\" on click=\"selectAll(this)\" /> (Select all)<br /> 
Thank you!
Jun 2 '07 #1
2 2243
dmjpro
2,476 Top Contributor
Welcome to TSDN.

Then add a condition to check whether the checkbox is disable or enable.
Best of luck.

Kind Regards.
dmjpro.
Jun 2 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
You could use
Expand|Select|Wrap|Line Numbers
  1. obj.getElementsByTagName('input');
to get all input elements within a particular object (obviously checking the type too).

If it's checkboxes with the same name, just access the name of the checkbox and loop through those instead of the whole form.
Jun 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
6593
by: Mike Lopez | last post by:
Hello. I need to set a checkbox to the "checked" state and prevent the user from unchecking it. I tried using "disabled", but then the value is not passed on the Post to an ASP page. Anyone...
2
27716
by: Travis.Box | last post by:
I have an MS Access userform with 16 Check Boxes. Each of the checkboxes has a different option value, which coincides with the Check Box name (eg. cb01.OptionValue = 1). At the bottom of the...
2
2197
by: limbo2u | last post by:
I'm using the following code for a checkbox that when clicked, either checks or unchecks a group of checkboxes on a form. The code works fine, except when there is only one checkbox in the group in...
19
8251
by: Taras_96 | last post by:
Hi everyone, How do you detect that a form element has been changed? This thread: ...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.