Yeah I know - it's asked and answered 100's of times. But I'm not happy with proposed solutions.

I know about HTML::FillInForm and other modules with similar functionality. But I haven't found any that would beside selecting right option in a <select> also dynamically make those.

To make it more clear. Inside my template (HTML::Template)

<select name="whatever"> Insert possible options here and of course select the right one </select>
I know about solution with CGI.pm that would generate the whole thing together with select but I use CGI::Simple - and I want to leave it possible for designer (or whoever) to say set class (CSS) for the particular select - or maybe add onChange JS event handler ...

Another solution would be :

<select name="whatever"> <!-- TMPL_VAR NAME="whatever_select" --> </select>
But then I end up with HTML generating code - which means I have html code inside my Perl code ...
<select name="whatever"> <!-- TMPL_LOOP NAME="whatever_select" --> <option value="<!-- TMPL_VAR NAME="id" -->" <!-- TMPL_VAR NAME="checke +d" -->><!-- TMPL_VAR NAME="value" --></option> <!-- /TMPL_LOOP --> </select>
Also looks kinda funky :) And it also requires work inside my code.

I was thinking of simply passing array(ref) of possible values that would be used for filling options. And then HTML::FillInForm would easily select right option. Any module that does that? If not, I might try to write it myself - but I'm not that good with parsing ...

Have you tried freelancing? Check out Scriptlance - I work there.

In reply to Populating options in html select. by techcode

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.