It's not overly flexible in terms of layout, but one should mention the CGI.pm solution if only for completeness:
$html .= $query->radio_group(-name => "my_parameter", -values => [qw/option1 option2/], -default => $existing_value, -labels => {option1=>"Option 1", option2=>"Option 2"}, -linebreak => "true");
It seems that CGI.pm uses "checked" instead of "selected", despite that selected is the spec. For more copious options, see your local CGI.pm documentation.
Update: In my sleep-deprived state, I somehow saw "drop-down list" and thought "radio group." Don't ask about the details. Anyways, all of the above does apply to popup_menu as well as radio_button, as mortis points out. Memo to self: Engage brain before noding.
perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'
In reply to Re: Dynamically marking a HTML select option as selected
by Chmrr
in thread Dynamically marking a HTML select option as selected
by ezekiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |