Solved

find the selected item in the selection list?

Posted on 2000-04-09
6
185 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Input from stdin for perl 6 118
compress files in RAR using perl 13 79
Perl Application JSON Receiving Strange Java Error 3 67
Perl script to delete older files 6 71
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 …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now