Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

find the selected item in the selection list?

Posted on 2000-04-09
6
Medium Priority
?
225 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
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.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
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

609 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