Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to keep selection when you select among multi-listbox?

Posted on 2003-03-06
4
Medium Priority
?
249 Views
Last Modified: 2008-03-06
could you show me how to keep previous selection when you select among multiple listbox? thanks
0
Comment
Question by:tony_w
3 Comments
 
LVL 1

Expert Comment

by:OKSD
ID: 8091325
Could you restate that? Maybe give an example, because I don't quite understand...
0
 
LVL 1

Accepted Solution

by:
nbthanh earned 200 total points
ID: 8195682
Ok,
Imagine that you have selected some item in a listbox and submitted the selection to your Perl script.
In your Perl script you retrieve what selected:

my $req = new CGI();
my @selections = $reg->param('listbox_name');
#convert a list into a hash for faster looking up
my %hash = map { $_, "1" } @selections;


Then output back to browser. Any item has been selected, you mark it as "selected". Here is a psedo-code:

print "<select ...blabla..>";
foreach my $item (@itemslist) {
  if ($hash{$item->{value}}) {
    print "<option value='$item->{value}' selected>$item->{text}</option>";
  } else {
    print "<option value='$item->{value}'>$item->{text}</option>";
  }
}
print "</select>";

Hope this help.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9694851
Nothing has happened on this question in over 7 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by nbthanh.

Please post any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question