Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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;


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://560399]
[Spenser]: It's a stripped down version on a NAS device.
[Spenser]: It's frustrating
[Spenser]: Perl 5.10.0
[Spenser]: It uses opkg to install software
[choroba]: 5.10.1 would be much better
[shmem]: there are so many ways thinkable to fix that situation, some feasible and some not, that I'm unable to give good advice.
[Spenser]: I installed 5.22 with opkg. I can use it with cpan. I'm actually trying to install perl-DBD-mysql, but couldn't with it. So I went back to the factory version, 5.10.
[Spenser]: So, nevermind about CPAN. I give up on the downgraded angle. I'm back to fighting to install DBD.
[shmem]: please open a SoPW. At what point is the perl-DBD-mysql installation failing?

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2018-03-17 12:42 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (224 votes). Check out past polls.