?
Solved

find the selected item in the selection list?

Posted on 2000-04-09
6
Medium Priority
?
217 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 200 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
Independent Software Vendors: 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

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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

741 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