I applaud you mentioning CGI.pm, it does have a solution - it's just not the radio_group method, it's popup_menu, or scrolling_list, depending on weather you want a single selection drop-down or a multi-value scrolling list box.
$html .= $query->scrolling_list( -name => 'my_parameter', -values => [qw/option1 option2/], -default => $existing_value, -labels => { option1 => 'Option 1', option2 => 'Option 2'}, -multiple => 'true', ); # or $html .= $query->popup_menu( -name => 'my_parameter', -values => [qw/option1 option2/], -default => $existing_value, -labels => { option1 => 'Option 1', option2 => 'Option 2'}, );
The other absolutely wonderful thing about CGI.pm is that if the parameter already has a value in the $query object (which you can set explicitly), it will automaticly have it's old value (i.e. it will stick) when you use $query to produce the html (that is if you don't set it explicitly as above). This is great for situations when you have to re-display an HTML page with a form to the user so they can either correct fields, or fill in required fields.

If you want to have a default value without overwriting the user's entry, an easy thing to do is:

$query->param('my_parameter',$defaultValue) unless defined $query->p +aram('my_parameter');

hth


In reply to Re: Re: Dynamically marking a HTML select option as selected by mortis
in thread Dynamically marking a HTML select option as selected by ezekiel

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.