throop has asked for the wisdom of the Perl Monks concerning the following question:
From a webpage form, how do I save a javascript variable's state as a CGI::param?
Background: I'm coding a set of cgi-bin tools using CGI::Session. The pages display an indentured datastructure (read in from XML::Simple::XMLin). 'Folders' —parts of the datastructure—are hidden / exposed by clicking on icons. The icons are <IMG> tags with onclick methods that call a javascript function, toggleFolder.
In turn, toggleFolder toggles a javascript variable – folder.style.display – between 'block' and 'none'.
The problem: This is all working fine. But when the user reloads the page, (i.e, POSTs a 'submit' to save his inputs) the state information for all the folders is lost. The javascript variables aren't immediately accessible to the CGI::param variables. So the page comes back up with all the folders closed and the user has to click repeatedly to get back to the state before the Submit.
My question: How do I copy the value of a javascript variable (like folder.style.display) over to a CGI::param variable? Do I do it within the javascript (within the function definition of toggleFolder)? or from Perl?
Is there a module that I should be looking at to do this?
(I'm reasonable Perl programmer, but a novice at javascript. I'm refactoring / adapting someone else's code.)
thanks
throop
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI: Saving javascript variables
by jZed (Prior) on Oct 31, 2007 at 19:52 UTC | |
by throop (Chaplain) on Oct 31, 2007 at 21:08 UTC | |
by jZed (Prior) on Oct 31, 2007 at 21:49 UTC | |
by Gangabass (Vicar) on Nov 01, 2007 at 04:33 UTC | |
|
Re: CGI: Saving javascript variables
by Crackers2 (Parson) on Oct 31, 2007 at 20:27 UTC | |
|
Re: CGI: Saving javascript variables
by aquarium (Curate) on Oct 31, 2007 at 21:20 UTC |