Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Friggin' checkboxes

 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic