in reply to Re: Generating Select elements with foreach loops
in thread Generating Select elements with foreach loops

Thats a nice way of doing it, however that just displays the static menu does it not?
What about comparing to the db hash and settting the value of selected to suit.
Sorry I'm not lazy, I've just never really used the CGI module in this way.
  • Comment on Re^2: Generating Select elements with foreach loops

Replies are listed 'Best First'.
Re^3: Generating Select elements with foreach loops
by davorg (Chancellor) on Jul 11, 2006 at 10:41 UTC

    Sorry, yes my example wasn't very clear. If -default is set to one of the values, then the correct item in the list is selected. I think you can get the required value from your %userRecord hash.

    If I change the code to:

    print popup_menu(-name => 'foo', -values => \@quantities, -labels => \%labels, -default => 25);

    Then I get the following output:

    <select name="foo" > <option value="1">Individual</option> <option value="5">5</option> <option value="10">10</option> <option selected="selected" value="25">25</option> <option value="50">50</option> <option value="100">100</option> </select>
    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Many thanks dave, you are most definitely

      'the man'