Kinda Urgent (to me, anyway) -> Javascript, postgres and checkboxes... Last big hurdle
Madison Kelly
linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Mon May 31 01:45:12 UTC 2004
Emma Jane Hogbin wrote:
> On Sun, May 30, 2004 at 03:33:48PM -0400, Madison Kelly wrote:
>
>> Along side each directory and file is a checkbox that I have yet to
>>make work and have been struggling with for the last two days. The idea
>>is that when a checkbox for a directory is checked that automatically
>>all sub directories and files will automatically become selected.
>
>
> I don't have enough information yet to solve this problem for you....will
> all files be available from the page that we're on, or just the "top level
> directories" for whatever directory you're in? If all files are displayed
> then this (in theory) will work. It's completely hypothetica though, so
> you'll have to do some testing and let me know where it does/not work. If
> the files are NOT all showing when you are trying to select sub-dirs then
> you're actually working with a Perl problem, not a JavaScript problem.
>
> Let me know how you do with this info....
>
> So let's say your HTML looks like this:
> <form name="listOfFiles" method="post" action="whatever.pl">
> <input type="checkbox" name="files" value="/path/to/file/1.txt" />
> <input type="checkbox" name="files" value="/path/to/file/2.txt" />
> <input type="checkbox" name="files" value="/path/to/another/file/1.txt" />
> <input type="checkbox" name="files" value="/path/to/another/file/again/1.txt" />
> <input type="checkbox" name="files" value="/path/to/another/file/again/2.txt" />
> (etc)
> <input type="button" name="whatever" value="And all subdirectories"
> onclick="andLower(document.listOfFiles.files)" />
>
> or maybe you do this onsubmit in which case:
> <form name="listOfFiles" method="post" action="whatever.pl"
> onsubmit="andLower(document.listOfFiles.files)">
>
>
> Then to select a "tree" of files your javascript might look something
> like this:
>
> function andLower (filesArray) {
> for (var i=0; i < filesArray.length; i++) {
> var thisFile = new String(filesArray[i].value);
>
> if (filesArray[i].checked == true) {
> // we've found an item which is currently checked
> // from here to the end of this section everything
> // should be turned "on"
> var lastSlash = thisFile.lastIndexOf("/");
> var thePath = thePath.slice(0, lastSlash);
> }
>
> // if this checkbox's filename starts with the checked path
> // it should also be checked
> var findMe = /^thePath/;
> if (thisFile.search(findMe) != -1) {
> filesArray[i].checked = true;
> }
> }
> }
Thank you so much!!
I am reading through your post now trying to understand how it works and
will try to implement it and report back.
To answer your question, perl queries the database for the directories
off of root and then any subdirectories that have been set to be
displayed for each. Any other subdirectory is not returned from the
database or shown. The files shown start off only as the ones in the '/'
of the working partition. When another directory is selected it's
files are read in from the database and shown. So all of the files in
the subdirectories of a selected file are not printed. I supposed to fix
this (if needed) I could read in -everything- on the partition and alter
views using viewable layers (dhtml?) but that would mean I would have to
learn how and my poor brain is at the breaking point!! :)
Okay, off to reading what you have shown me!
Madison
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list