473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Select/Deselect All With Checkbox

Hi guys,

I'm having some trouble writing code for this purpose of select/deselect all function.

I do not want to use the form "name" because i want ensure that it is html strict. Also my form is being tracked so all input fields have a different name. I want to be able to do this by assigning each input checkbox field with an "id" tag. Any suggestions?
Jul 25 '07 #1
3 4497
iam_clint
1,208 Expert 1GB
how about this for example
Expand|Select|Wrap|Line Numbers
  1. function SelectAll(val) {
  2.   var objects = document.getElementsByTagName("input"); //all input objects
  3.   for (i=0; i<objects.length;i++) { //start for loop
  4.     if (objects[i].getAttribute("type")=="checkbox") { objects[i].checked = val; } //checkbox found set its checked attribute
  5.   }
  6. }
  7.  
Then call the function like this

Expand|Select|Wrap|Line Numbers
  1. <input type="button" onclick="SelectAll(true);" value="Select All">
  2. <input type="button" onclick="SelectAll(false);" value="Deselect All">
  3.  
Jul 25 '07 #2
Thanks for this...now the problem with this is that I am actually using a "checkbox" itself to deselect all the other checkboxes. It works, but the checkbox I'm using I want to be able to be checked. Does that make sense?



how about this for example
Expand|Select|Wrap|Line Numbers
  1. function SelectAll(val) {
  2.   var objects = document.getElementsByTagName("input"); //all input objects
  3.   for (i=0; i<objects.length;i++) { //start for loop
  4.     if (objects[i].getAttribute("type")=="checkbox") { objects[i].checked = val; } //checkbox found set its checked attribute
  5.   }
  6. }
  7.  
Then call the function like this

Expand|Select|Wrap|Line Numbers
  1. <input type="button" onclick="SelectAll(true);" value="Select All">
  2. <input type="button" onclick="SelectAll(false);" value="Deselect All">
  3.  
Jul 25 '07 #3
vee10
141 100+
Thanks for this...now the problem with this is that I am actually using a "checkbox" itself to deselect all the other checkboxes. It works, but the checkbox I'm using I want to be able to be checked. Does that make sense?
hi ,

This may solve ur problem

Expand|Select|Wrap|Line Numbers
  1. function SelectAll() 
  2.     {
  3.       var objects = document.getElementsByTagName("input"); //all input objects
  4.      for (i=0; i<objects.length;i++) { //start for loop
  5.      debugger
  6.  
  7.      if (objects[i].getAttribute("type")=="checkbox")
  8.       { 
  9.       objects[i].checked = document.getElementById("SelOrDelsel").checked; } //checkbox found set its checked attribute
  10.       }
  11. }
  12.  
and the check for which u need to check or deselct the other checkboxes
Expand|Select|Wrap|Line Numbers
  1.   <input type="checkbox" id="SelOrDelsel" onclick="SelectAll();" value="Select All" />Select / DeSelect
  2.  
Jul 26 '07 #4

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

Similar topics

4
by: Michael Champagne | last post by:
We have an application to where you can select/deselect all checkboxes in a checkbox array by clicking a 'master' checkbox at the top of the screen. This seems to work fine unless there is only...
3
by: Notorious | last post by:
The following Javascript line will deselect the currently selected index of a select box for Netscape and Firefox, but will not deselect in Explorer 6. theForm.assignedLic.options.selected =...
5
by: _andrea.l | last post by:
I have n checkboxes and 1 checkbox 'SELECT ALL'. for example: <form action="" method="get"> <input name="sa" type="checkbox" value="v"> select all <input name="c1" type="checkbox" value="v">...
6
by: GSteven | last post by:
(as formerly posted to microsoft.public.access.forms with no result) I've created a continuous form which is based on a straightforward table (ex - customers - 100 records). On the form there is...
5
by: colleen1980 | last post by:
Hi: In my table there is a field of type checkbox. I create a button on my form and wants to deselect all the checkboxes in that field (PrintQueue). Table: Research_New PrintQueue Format Yes/No...
1
by: VBNovice05 | last post by:
I run a search on my database and get items that fit that search in a datagrid. There are checkboxes already for each item. I need to create a select/deselect all checkbox at the top of the...
4
by: 159789 | last post by:
Hi, I am new to javascript. I want to select all the checkboxes or deselect all in a form, based on the state of one checkbox. Here is the code: <html> <script language="JavaScript">...
18
by: klove1209 | last post by:
Good afternoon, I would like to know if anyone can direct me as to how I can write a VBA code to deselect about 26 check boxes, for all records. I have been searching the internet, but I...
27
kcdoell
by: kcdoell | last post by:
Hello: I am a newbie with Java coding... I have a form that I created in Word. Within that form it had a place where the user could selected certain states or all states via a checkbox. I used...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.