?
Solved

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

Posted on 2003-03-06
4
Medium Priority
?
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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

770 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