http://qs321.pair.com?node_id=760278

anbutechie has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: modifying listbox value?
by Corion (Patriarch) on Apr 27, 2009 at 06:55 UTC

    Maybe you want to show us the relevant part of the code you already have? In general, the idea would be to only output val1, val2 when needed, and val3, val4 otherwise.

    But you might still be under a misconception how CGI works, so it's hard to tell without seeing code and a more exact description of what you want to happen.

Re: modifying listbox value?
by dorward (Curate) on Apr 27, 2009 at 07:01 UTC

    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 );