Im a bit of a Perl newbie and I keep going round in circles. I want to create a drop down menu of 'Month Year ' combinations, the HTML would look like this:
<option selected value="Select a month">Select a month</option> <option value="0305">March 2005</option> <option value="0405">April 2005</option> <option value="0505">May 2005</option> <option value="0605">June 2005</option> <option value="0705">July 2005</option></select>
I want to pass the value the user selects in this drop down to a variable so that I can use it in Perl to look for a file with a name that correponds to the selected value and if it finds the file, to open it. I'm trying to create the drop down field like this:
my %month = ( "March 2005" => "0305", "April 2005" => "0405", "May 2005" => "0505", "June 2005" => "0605", "July 2005" => "0705", ); print option_list(\%month); sub option_list { my $options = shift; return "<select>\n" . (join '', map{ qq!<option value="$options->{$_}">$_</option>\n! } keys %$options ) . "</select>\n"; }
I've got the subroutine looking for the filename and opening it working, what I can't get to work is: 1. How to get the selected value out of the Drop Down Menu 2. How to get the Drop Down month to display in month order. (They currently display in this order in the list: June 2005, March 2005, July 2005, May 2005, April 2005 Can anyone help?

20050317 Edit by castaway: Changed title from 'Extracting selelcted values from HTML Select Menus'


In reply to Extracting selected values from HTML Select Menus by kjg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.