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 Friggin' checkboxes 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 "Friggin Watch "Friggin New topic

Friggin' checkboxes

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I have a large file that I am reading into ASP (boo hiss I know, but its company standard).
Anyway, this file is a collection of directory and file names.
Each entry should be a checkbox, and each group of files in that directory should belong to the direcotries checkbox group. (Follow me so far).
My output looks something like:
[]Directory Name
And so on with each directory and group of files being its own independant group.
I need to actions:
1) If I check a directory all subsequent files in that group get checked and vice versa, if I uncheck it, all files should be unchecked.
2) Provide a selectAll button to select every checkbox on the page all at once.
I can get the first part of number one, but I can't get the uncheck to work. I am calling on_Click="function_here" (I know it's spelled wrong but this board wouldn't let me post that otherwise.)but it seems the unchecking never gets registered.
The problem with part two is, you will never know how many checkboxes there are because it will vary depending on the user. I am not sure how to get all the boxes checked.
Any ideas?
[ October 22, 2002: Message edited by: ryan headley ]

Ryan Headley<br /><a href="" target="_blank" rel="nofollow"></a>
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
UPDATE: I got number one figured out, rather simple really. Could have sworn I went thru it earlier, but number 2 is still giving me a hard time.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
run this below....shows you the basic idea.
<form name="A1">
document.write('<input type="checkbox" name="C'+j+'" value="ON" >');
<a href="javascript:SelectAll()">[Select All]</a>
var AllChecked=false;
function SelectAll(){
else AllChecked=true;
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Your code works, but not for mine.
The difference is, I think anyway, is that my checkboxes are being built thru ASP. In some of these pages there will be 26 or more "groups" of checkboxes, each with the name of "fileGroupX" where X is a number. All files of the same group will have the same number.
What I've done so far is this:

but I get an error saying that document.deletefiles.[filegroup + i].checked is null or not an object.
I've tried every varation of the last line:
document.deletefile["fileGroup" + i].checked
document.deletefile.fileGroup[i].checked etc, etc and nothing is working. All give the same error.
In the above code, dircount is the number of checkbox groups. I pass that ASP variable into my javascript and it recognizes the correct number.
What am I doing wrong?
I agree. Here's the link:
subject: Friggin' checkboxes
It's not a secret anymore!