Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: modifying listbox value?

by dorward (Curate)
on Apr 27, 2009 at 07:01 UTC ( #760286=note: print w/replies, xml ) Need Help??

in reply to modifying listbox value?

It depends on how you are building the content of the "list box" (by which I assume you mean "An HTML select element").

Assuming you are using the built in methods of the CGI module (not the approach I would use, I'd much rather separate things out with Template-Toolkit), then just pass different data after testing for the condition. The approach is pretty much the same with any other method, it just needs adapting for where you pass the data to.

my $condition = 1; my @options = qw/val1 val2/; if ($condition) { @options = qw/val3 cal4/; } my $q = CGI->new(); print $q->Select( map { $q->option($_) } @options );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://760286]
[1nickt]: I am stumped, maybe someone brainy can clear my mind?
[1nickt]: This code does what I expect on the CLI: perl -wE 'sub x { 0 and 1 } say x()'
[1nickt]: (prints "0")
[Corion]: Hi 1nickt!
[1nickt]: When I put it in a file, I get the following: "Replacement list is longer than search list at line 4. syntax error at line 4, at EOF ...
[1nickt]: ... (Might be a runaway multi-line ;; string starting on line 3)"
[erix]: ( ha, the inmates of the retirement home have taken the kids to the cafe -- Good! :) )
[1nickt]: (there are three lines in the file)
[erix]: na namesti ( "At The German" ? )
[1nickt]: great goddess almighty, it's the subroutine name!

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2017-12-12 13:36 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (332 votes). Check out past polls.