Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Generating Select elements with foreach loops

by hv (Parson)
on Jul 11, 2006 at 11:21 UTC ( #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;


Comment on Re: Generating Select elements with foreach loops
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2015-12-02 08:30 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (37 votes), past polls