473,372 Members | 884 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,372 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 4501
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.