aspose file tools*
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
Author

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
[]Filename
[]Filename
[]Directory
[]Filename
[]Filename
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="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</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
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
run this below....shows you the basic idea.
<html>
<head>
</head>
<body>
<form name="A1">
<p>
<script>
for(j=1;j<=Math.random()*20+1;j++){
document.write('<input type="checkbox" name="C'+j+'" value="ON" >');
}
</script>
</p>
</form>
<a href="javascript:SelectAll()">[Select All]</a>
<script>
var AllChecked=false;
function SelectAll(){
if(AllChecked)AllChecked=false;
else AllChecked=true;
for(i=1;i<=document.A1.length;i++){
document.A1["C"+i].checked=AllChecked;
}
}
</script>
</body>
</html>
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?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Friggin' checkboxes