473,399 Members | 3,656 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,399 software developers and data experts.

tweak 'select all' js function

Hi,

I have a select all js function that works nicely but could use a little tweaking. I recently created a new form that includes hidden checkboxes using CSS that are made visible during a menu select which updates the display attribute from hidden to block. With this new method of storing all required fields on a single jsp the select all function is not working as I'd like it to. When selected, all the form fields hidden and none hidden are selected. So now it is necessary to validate the display attribute before the checkbox is selecting

Here are the details;

Expand|Select|Wrap|Line Numbers
  1. function checkall(formname,checkname,state){
  2.    var checkboxes=eval("document.forms."+formname+"."+checkname)
  3.    for (cb=0;cb<checkboxes.length;cb++)
  4.    checkboxes[cb].checked=state
  5. }
  6.  
  7.  
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. ..... snip ....
  4.  
  5. <div id="menu1" class=hide>
  6.  <div id="main">
  7.   <input type="checkbox"  name="Topic" value="addtopic20"/>
  8.   add Topic 20
  9.  </div>
  10. </div>
  11.  
  12. <div id="main">        /* always visable*/
  13.  <div>
  14.   <input type="checkbox" name="Topic" value="maintopic1" />
  15.   main topic 1 
  16.  </div>    
  17.  <div>
  18.   <input type="checkbox" name="Topic" value="maintopic2" />
  19.   main topic 2 
  20.  </div>    
  21. </div>
  22.  
  23. <a  href="javascript:checkall('queryForm','Topic',true)">Select all</a>  / </font>
  24.  
  25. </html>
Thanks for the suggestions.
Aug 7 '07 #1
1 1578
acoder
16,027 Expert Mod 8TB
Since the checkboxes are within divs which are within divs whose class name is set to hide or whatever, check the parentNode's parentNode's className is equal to "hide".

PS. an ID must be unique. You can't have two elements with the id "main".
Nov 3 '07 #2

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

Similar topics

0
by: Luke Airig | last post by:
I am trying to merge two xml files based on common date/time and then write out a tab-delimited xml file with the header record from one of the input files concatenated in front of the merged...
2
by: 'perch | last post by:
I'm trying to tweak the Google toolbar search button to do two things; to include selected text as a string search (i.e. as though I'd entered the text in ""), and to open a new page for the search...
3
by: Jane D | last post by:
I have got a bookmarklet for use with Opera which highlights all occurrences of some text in the displayed page. I find it very useful. Sometimes I need to use two or three different colours...
2
by: Harvey, Allan AC | last post by:
Hi all, I was hoping someone might be able to set me straight so that I can get some select performance improvements. The table in question has several thousand rows currently, planning several...
1
by: CR1 | last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to...
16
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
1
by: capdownlondon | last post by:
Im using the following code to duplicate a record varCnt(retrieved from a combo box on the form) many times, and it only duplicates the record with the fields present on the form for that record....
2
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I have some code (given to me), but I don't know alot about ASP, so I was hoping someone here can help. The code below will scan a folder and subfolder with a date/time input and...
8
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I have some code (given to me), but I don't know alot about ASP, so I was hoping someone here can help. Running on Win 2008 server. The code below will scan a folder and subfolder...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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,...

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.