Solved

find the selected item in the selection list?

Posted on 2000-04-09
6
213 Views
Last Modified: 2010-03-05
in the html file I have the following:<select NAME=\"fp\" SIZE=\"1\">
            <option value = \"dont_register\">I dont want to register </option>
                <option value = \"Fp1\">Fp 1</option>
                <option value = \"Fp2\">Fp 2</option>
                <option value = \"Fp3\">Fp 3</option>
                <option value = \"Fp4\">Fp 4</option>
                <option value = \"Other\">Other</option>
              </select></font>


this html's form invoke a cgi file that want to find which select item is selected? so in the cgi,  I want to use

if($values{'fp'}=="Fp2")
{
   do something
}

but it seems dont work at all ,

0
Comment
Question by:syu1
[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
6 Comments
 
LVL 3

Expert Comment

by:jyu_88
ID: 2698906
you'd use CGI.pm
as such
#! /usr/bin/perl
use CGI;
my $query = new CGI;
# instantiate a CGI object
# all form param will be parsed and stored in a hash
called param
$value = $query->param('pf');
if ( $value eq "Fp1" ) {
# do something
}
your code may have two things prevent it from working:
1) values from form selection is not parsed and retrieved properly
2) == is for numeric comparison, eq is for string compaer
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2700486

Add the foll 2 lines before your if statement and see if you can see anything on the screen. pl. let me know the output

print "Content-type: text/html\n\n";
print "<B>$values{'fp'}</B>\n";

if($values{'fp'}=="Fp2") {
  do something
}

Also it would be nice, if you can post the entire code in this forum.

0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 2701033
perl -Mdiagnostics -w
if( $values{'fp'}=="Fp2" ) { }
Argument "Fp2" isn't numeric in eq at - line 1 (#2)
   
    (W) The indicated string was fed as an argument to an operator that
    expected a numeric value instead.  If you're fortunate the message
    will identify which operator was so unfortunate.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:syu1
ID: 2701573
iyu 88 :

thanks lot , I really appreciate it, it
really should use eq not ==
0
 

Author Comment

by:syu1
ID: 2701578
iyu 88 :

thanks lot , I really appreciate it, it
really should use eq not ==

0
 

Author Comment

by:syu1
ID: 2701589
iyu 88:

you deserve the point, sorry I clike the wrong button.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

717 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