Well I finally got this to work. My problem was that, instead of "printing" the menu, I needed to "return" it and then call it with a placeholder on the html page (I apologize if that's not the proper terminology). Here's what I have:

sub make_year_range_html { my $year = 1900 + (localtime)[5]; my $html = qq{<select name="CC_ExpDate_Year">\n}; $html .= qq{<option value="" selected>--</option>\n}; for my $ccy ($year .. $year + 9) { $html .= qq{<option value="$ccy">$ccy</option>\n}; } $html .= qq{</select>\n}; return $html; }

Next, I created the placeholder with this code:

$main::global->{form}->{year_range} = make_year_range_html();

Then I put the placeholder on the html page, like so:

<! year_range>

It works perfectly! Thanks to everyone who helped me with this. This has taught me a lot about how Perl works in a cgi environment, especially how to create sub routines and using the output with placeholders. Exciting stuff!

Ted


In reply to Re: Drop Down Year List by tedspinkle
in thread Drop Down Year List by tedspinkle

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.