I am trying to learn CGI.pm and am having a bit of trouble with getting the values out of radio buttons.
I think the problem lies in the fact that I dont understand the way radio_button stores its selected value.
radio_group(-name=>['add_remove'], -values=>['Add','Remove'], -default=>'Add', -labels=>\%labels),p,
and when I try to print back whats in the add_remove value I get nothing
"Rule: ",em(param('add_remove')),p,
I thought that the add_remove instance of radio_buttone would just contain whatever value is checked by default or if it is changed. Can anyone explain what is going on? Or can post an example of a working radio button in CGI.pm I can prolly figure it out.
#!/usr/bin/perl -w use CGI qw/:standard/; print header, start_html('Service Request Form'), h1('Service Request Form'), start_form, "Name:<br>",textfield('name'),p, "Phone:<br>",textfield('phone'),p, "Date:<br>",textfield('date'),p, "Email:<br>",textfield('email'),p, "Add or Remove this rule", "<br>", radio_group(-name=>['add_remove'], -values=>['Add','Remove'], -default=>'Add', -labels=>\%labels),p, "Source:<br>",textfield('source'),p, "Destination:<br>",textfield('destination'),p, "Service:<br>",textfield('service'),p, "What do you want to happen to this traffic?", "<br>", radio_group(-name=>['action'], -values=>['Accept','Reject'], -default=>'Accept', -labels=>\%labels),p, "Please describe what you are trying to accomplish:<br>", textarea(-name=>'description', -rows=>10, -columns=>50),p, submit, end_form, hr,"\n"; if (param) { print "Name ",em(param('name')),p, "Phone Number: ",em(param('phone')),p, "Date: ",em(param('date')),p, "Email: ",em(param('email')),p, "Rule: ",em(param('add_remove')),p, "Source: ",em(param('source')),p, "Destination: ",em(param('destination')),p, "Service: ",em(param('service')),p, "Action: ",em(param('action')),p, "Description: ",em(param('description')),p, } print end_html;

In reply to Please help with my CGI.pm misinterpritation by synjoo

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.