Solved

find the selected item in the selection list?

Posted on 2000-04-09
6
174 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

10 Experts available now in Live!

Get 1:1 Help Now