Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Generating Select elements with foreach loops

by hv (Prior)
on Jul 11, 2006 at 11:21 UTC ( [id://560399]=note: print w/replies, xml ) Need Help??


in reply to Generating Select elements with foreach loops

The error is in the check for '1' - you are checking the user record, when you should be checking $_, the quantity for which you are currently generating the option field:

if ($_==1){# show name 'individual' for qty 1 else show number

I find this sort of output most easily generated with (s)printf:

@quantities = ('1','5','10','25','50','100'); printf( '<option value="%s"%s>%s</option>', $_, # option value is the quantity ($_ == $userRecord{$pack_qty}) ? ' selected' : '', ($_ == 1) ? 'Individual' : $_ ) for @quantities;

Hugo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://560399]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-03-29 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found