Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrays

Status
Not open for further replies.

nappaji

Programmer
Mar 21, 2001
76
US
I have an array into which I read in some values from a scroll list . I assign this array onto a second array.
ex:
@fnames = query->param('scroldev');
@oldfnames = @fnames;

I have a button on te form. When I click it , I basically return to the same page and try to print @oldfnames. But, it gives me a blank.

How do I presernve the contents of oldfnames??
Does it get refreshed ??

Please help.
 
Each iteration of a CGI app is a totally separate event and is unrelated to any other iteration of that same code...... unless you do something to help the second iteration 'remember' the first. There are a few ways of doing that. You can use hidden fields in your html or you use cookies. If you use a hidden field in your html, with several items in your scroll list selected,

@scroll_stuff = $query->param('scroldev'); # note you were missing a '$' above
$joined_scroll_stuff = join '|',@scroll_stuff;
print &quot;<input type='hidden' name='prev_scroldev' value=\&quot;$joined_scroll_stuff\&quot;>&quot;;

# Then, when that page is submitted you can get the previous selections via
$prev_scroll_stuff = $query->param('prev_scroldev');
@prev_scroll_items = split(/\|/,$prev_scroll_stuff);

If you are interested in using cookies, take a look at the docs for CGI.pm. If you don't have that module, I suggest you get it and figure out how to use it. It is not a magic bullet for doing CGI code, but, it has tons of utility. I use it a lot.

HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top