Solved

in mutiple selection list, how to get the selected item?

Posted on 2000-03-19
7
222 Views
Last Modified: 2010-03-05
in the Html, I use  mutiple selection list, how to get the selected item?

in the cgi(or Pl) , how to get the selected item?
0
Comment
Question by:she2
[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
  • 2
7 Comments
 
LVL 1

Expert Comment

by:lambda
ID: 2635268
In Perl, the selected value will be passed along with the query string. U just have to decode the query string & get the value.

If ur select box has name 'sel_list',

if ($ENV{REQUEST_METHOD} =~ /POST/i)
{
   read(STDIN, $cache, $ENV{'CONTENT_LENGTH'});
}
else
{
  $cache = $ENV{'QUERY_STRING'};
}

   @pairs = split(/&/, $cache);
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $FORM{$name} = $value;
   }

print "the selected value is $FORM{'sel_list'}";
0
 
LVL 1

Expert Comment

by:lambda
ID: 2635272
Sorry, the first line shld read,

if ($ENV{'REQUEST_METHOD'} =~ /POST/i)
0
 
LVL 1

Expert Comment

by:lambda
ID: 2635311
Actually the above correction wasn't necessary. I tried it only after I posted it !
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Accepted Solution

by:
makerp earned 50 total points
ID: 2635363
use cgi.pm

i.e.

# the module
use CGI;
# create a cgi object
$query = new CGI;
# use the param methos of our cgi object to obatin a variable passed from our calling form
print("my selection was : ".$query->param('selection1'));

cgi.pm contains a whole host of methods to do the cgi donkey work for you. cpan or activestate have it for download. every body uses it. you dont need to worry about decoding querysrings etc with it.
0
 
LVL 10

Expert Comment

by:makerp
ID: 2635366
the same method is used to get values from all form input contols
0
 

Author Comment

by:she2
ID: 2636539
makerp:

thanks!, but $query->param('selection1')
should be arry of string, how to set up the array of string, and how to access?
0
 
LVL 1

Expert Comment

by:lambda
ID: 2638809

@values = $query->param('selection1');
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

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

623 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