in reply to Creating HTML radio button group with text field

Here was my CGI.pm solution (with less relevant details stripped out):
my @values = qw( a b c d ); my %labels = ( a => 'Friend', b => 'Magazine (please specify:)', c => 'Internet', d => 'Other', ); $labels{$_} = $cgi->escapeHTML($labels{$_}) for keys %labels; $labels{b} .= $cgi->textfield(-name => 'magname'); print $cgi->start_form(); $cgi->autoEscape(0); print $cgi->radio_group(-name => 'question', -values => \@values, -linebreak => 'true', -labels => \%labels); $cgi->autoEscape(1); print $cgi->endform;
I didn't like having to turn off autoEscape() and explicitly escape the other entries, so I was looking for a cleaner solution -- but it looks like that's as good as it gets (with CGI.pm, at least).

Thanks jeffa, podmaster.

Impossible Robot

Replies are listed 'Best First'.
Re^2: Creating HTML radio button group with text field
by Anonymous Monk on Sep 09, 2009 at 19:39 UTC

    This works for me however the only problem I get now is that whenever I click in the textfield, the focus always returns to the actual radiobutton so I can't actually type in the textfield