File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Function to select all Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Function to select all" Watch "Function to select all" New topic

Function to select all

Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 195
I have this function

It is suppose to �check all� check boxes when the link is selected but it isn�t working in IE (or FF but IE is what I am trying for). I tried using FF error console but I don�t get any errors�I know the name of the checkboxes are all the same but that is needed for other functionality.
Any ideas on what could be the cause?

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Do not check for the value of on/off, look at the check state of the checkbox.

Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 195
OK-I tried that it makes the code cleaner but it still fails to function...

function CheckAll() {

var i;
//Check all or Uncheck all awards...
for ( i in ListRecordForm.p_search_award_type ) {
if ( ListRecordForm.p_search_award_type[i].checked ) //turn them off
ListRecordForm.p_search_award_type[i].checked = false;
else //turn them off
ListRecordForm.p_search_award_type[i].checked = true;

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Or you could save yourself some gray hair and do it with jQuery. The code to check all checkboxes:

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Function to select all
It's not a secret anymore!