Straight from the guts of CGI.pm, where you should've had at least one visit ;)
#### Method: radio_group # Create a list of logically-linked radio buttons. # Parameters: # $name -> Common name for all the buttons. # $values -> A pointer to a regular array containing the # values for each button in the group. # $default -> (optional) Value of the button to turn on by default. + Pass '-' # to turn _nothing_ on. # $linebreak -> (optional) Set to true to place linebreaks # between the buttons. # $labels -> (optional) # A pointer to an associative array of labels to print nex +t to each checkbox # in the form $label{'value'}="Long explanatory label". # Otherwise the provided values are used as the labels. # Returns: # An ARRAY containing a series of <INPUT TYPE="radio"> fields #### 'radio_group' => <<'END_OF_FUNC', sub radio_group { my($self,@p) = self_or_default(@_); my($name,$values,$default,$linebreak,$labels, $rows,$columns,$rowheaders,$colheaders,$override,$nolabels,@oth +er) = rearrange([NAME,[VALUES,VALUE],DEFAULT,LINEBREAK,LABELS, ROWS,[COLUMNS,COLS], ROWHEADERS,COLHEADERS, [OVERRIDE,FORCE],NOLABELS],@p); my($result,$checked); if (!$override && defined($self->param($name))) { $checked = $self->param($name); } else { $checked = $default; } my(@elements,@values); @values = $self->_set_values_and_labels($values,\$labels,$name); # If no check array is specified, check the first by default $checked = $values[0] unless defined($checked) && $checked ne ''; $name=$self->escapeHTML($name); my($other) = @other ? " @other" : ''; foreach (@values) { my($checkit) = $checked eq $_ ? qq/ checked="checked"/ : ''; my($break); if ($linebreak) { $break = $XHTML ? "<br />" : "<br>"; } else { $break = ''; } my($label)=''; unless (defined($nolabels) && $nolabels) { $label = $_; $label = $labels->{$_} if defined($labels) && defined($labels- +>{$_}); $label = $self->escapeHTML($label,1); } $_=$self->escapeHTML($_); push(@elements,$XHTML ? qq(<input type="radio" name="$name" value= +"$_"$checkit$other />${label}${break}) : qq/<input type="radio" name="$name" va +lue="$_"$checkit$other>${label}${break}/); } $self->register_parameter($name); return wantarray ? @elements : join(' ',@elements) unless defined($columns) || defined($rows); return _tableize($rows,$columns,$rowheaders,$colheaders,@elements) +; } END_OF_FUNC
perl -MData::Dumper -MCGI=:all -e"print Dumper radio_group('IamGroup', +[qw/one othe r/],'one','linebreaks');" perl -MCGI=all -e"print textfield('other')"
Now what I'm wondering is how is it that you didn't happen to stumble accross the CGI documentation, or even its guts?

P.S. -- here's a few *secret* links, don't tell nobody ( CGI, How to RTFM, http://ovid.perlmonk.org, http://stein.cshl.org/, perlsec)

update: Whaza?

1) No the CGI documentation does not explicitly state how you can do what you want (you're doing some odd things, and it'd be crazy for the documentation to reflect that).

2) Nooooo, If you don't know how to use certain functions, or they're not documented to your satisfaction, just crack open CGI.pm (and yeah, you could borrow, but that wasn't my point)

3) Didn't mean to imply you should modify CGI.pm

Yes, you missed my point completely (I guess I should've been more explicit, kinda like jeffa up there).

I just wanted to point out to you, radio_group (which returns a list) and textfield, two CGI.pm functions, which *you* can use to solve your problem. You have to use your imagination as to how to do it (i ain't writing code like jeffa, ain't got time)

Hopefully that clarifies it (if not, update your reply).
 

Look ma', I'm on CPAN.


** The Third rule of perl club is a statement of fact: pod is sexy.

In reply to (podmaster) Re: Creating HTML radio button group with text field by PodMaster
in thread Creating HTML radio button group with text field by impossiblerobot

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.