1. How to get the selected value out of the Drop Down Menu

You have to give the select a name, so that the browser will send it. In your CGI backend, you then check what value has been sent with that name. So, you need to change the line

"<select>\n" .

to something like:

"<select name='date'>\n".

See the forms section of the HTML specifications for how to send it, and the CGI or CGI::Lite modules on how to receive it.

2. How to get the Drop Down month to display in month order.

You just need to tell the program what order to print the values -- keys will return in what seems to be a random order (it isn't, but it's not an order that's useful for this). You'll want to change the lines:

(join '', map{ qq!<option value="$options->{$_}">$_</option>\n! } keys %$options ) .

to something like:

(join '', map{ qq!<option value="$options->{$_}">$_</option>\n! } sort sort_function keys %$options ) .

and add a function sort_function that can correctly order your values. See sort for information about writing such a function.


In reply to Re: Extracting selected values from HTML Select Menus by jhourcle
in thread 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.