Kinda Urgent (to me, anyway) -> Javascript, postgres and checkboxes... Last big hurdle

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Mon May 31 01:50:14 UTC 2004


Anton Markov wrote:
> -----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")>

   Oh Anton you darling that looks like the ticket!! (The /id/ tags). I 
don't know how to use it yet but now I have something to work towards 
that looks like what I am already doing with the 'file_parent_dir' 
value!! Woohoo! I don't mind learning when I have an idea of -what- to 
learn (which until now I didn't - hence my frustration and desperation!)

Thank you very much!!

Madison

PS - I will let you know when it is ready!!
--
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