Kinda Urgent (to me, anyway) -> Javascript, postgres and checkboxes... Last big hurdle
Anton Markov
anton-F0u+EriZ6ihBDgjK7y7TUQ at public.gmane.org
Mon May 31 01:23:34 UTC 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Madison,
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. Then
> (either at that moment or when the user clicks an "Update" button) the
> files that have been selected need to have their 'file_backup boolean'
> set to true so that when the backup is run on that given partition it
> will grab any directory or file which has been set to 'true' (plus any
> new files that have since been created that exist in a directory which
> has been selected). I need the reverse to occur, too. When a user
> unchecks a file or directory that file or that directory and all of
> it's
> subdirectories and folders need to be have their 'file_backup boolean'
> set to false.
I have once done something similar to what you are doing with the
checkboxes, so here is something that may help:
(sorry for the long lines)
> <form action="submit.cgi" method="get" target="_new">
>
> <input type="checkbox" name="/home" id="/0"
onchange="chkdirs(this.id)"> /home </li>
> <ul>
> <li><input type="checkbox" name="/home/www" id="/0/0"
onchange="chkfile(this.id)"> www </li>
> <li><input type="checkbox" name="/home/anton" id="/0/1"
onchange="chkfile(this.id)"> anton </li>
> </ul>
>
> <input type="submit" value="UPDATE">
>
> </form>
>
> <script language="Javascript">
>
> function chkdirs(node_id)
> {
> var parent = document.getElementById(node_id);
> var child;
>
> for(i=0; child = document.getElementById(node_id + "/" + i); i++)
> {
> child.checked = parent.checked;
> }
> }
>
> function chkfile(node_id)
> {
> var file = document.getElementById(node_id);
> var hierchy = node_id.split("/");
> hierchy.pop();
> if(parent = document.getElementById(hierchy.join("/")))
> parent.checked = file.checked;
> }
>
> </script>
Basically, you would name the checkboxes whatever you want, because the
key is to use the /id/ attribute. You perl script would generate the IDs
("/0/1", etc.) by simply numbering each file in the directory. This way
we can transverse it like an array using a /for/ loop and the
document.getElementById function until we run into a non-existant ID.
I also created a chkfile function to show how you can manipulate a
parent by knowing a child ID. In this case unchecking a file unchecks
the parent directory. You can transvers the entire hierchy backwards by
using hierchy.pop() in a loop. This sample requires a bit more work, but
I hope it is clear enough to help you.
> PS - When this is done I would love to announce it here for peer review.
> Would that be acceptable use of the list?
I don't know if it's "acceptable", but I would definitely like to take a
look at your program when it's finished. I've been looking for a good
backup program for a while now.
- --
Anton Markov <("anton" + "@" + "truxtar" + "." + "com")>
GnuPG Key fingerprint =
5546 A6E2 1FFB 9BB8 15C3 CE34 46B7 8D93 3AD1 44B4
*** LINUX - MAY THE SOURCE BE WITH YOU! ***
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAuokVRreNkzrRRLQRAlgTAJ0b6LRf1GDp3p5kTnH3sNUyIi53BwCeNB7S
6MYaRs/9EmvZS8lNTZvWfWQ=
=B9s0
-----END PGP SIGNATURE-----
--
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