Satanya has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am having dificulties trying to pull the values from radio buttons in the html script below, with the my cgi script:

<tr> <td><span class="category">Reporting Dashboard</span></td> <td><input type=text size=18 name="dashboardUse" value=""></td> <td><span class="note"><input type=radio name="dashboard" id="dash +board1" value="">1&nbsp;<input type=radio name="dashboard" id="dashbo +ard2" value="">2&nbsp;<input type=radio name="dashboard" id="dashboar +d3" value="">3&nbsp;<input type=radio name="dashboard" id="dashboard4 +" value="">4&nbsp;<input type=radio name="dashboard" id="dashboard5" +value="">5</span></td> </tr>

The script runs with out error, and sends me the formatted email. However, I do not see the values for the radio buttons. Here is some of my code. I am not certain how to go about fixing this. In my script I have pointed to the parameter named "dashboard" where the value would be stored after a person clicks the button.

Any info would be welcomed.

my ($reportingdashboard) = $main::cgi->param('dashboardUse'); my ($satisfactiondash) = $main::cgi->param('dashboard');

Thanks again for all of your help.

newbie Satanya

Replies are listed 'Best First'.
(Ovid) Re: cgi script does not pull the values from the radio buttons
by Ovid (Cardinal) on Sep 07, 2001 at 23:39 UTC

    This is not a Perl problem. All of your radio buttons have the attribute of value="", so no value is sent regardless of whether or not you check one of the radio buttons. Assign them values and that will take care of you problem.

    Also, you shouldn't use a globally defined CGI object. You're just begging for trouble. See 'use strict' is not Perl for more info.

    Cheers,
    Ovid

    Vote for paco!

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      Thanks so much for the info. I will tell my html people that the need to fix there code. Thanks a bunch.

      This helps so much.

      Satanya

Re: cgi script does not pull the values from the radio buttons
by Jazz (Curate) on Sep 08, 2001 at 04:11 UTC
    Actually, it looks like the html code is off.

    <input type=radio name="dashboard" id="dashboard2" value="">2

    Here, if someone clicks this button, the value assigned is blank (value=""). It seems like you're using id the way you really wanted to use value...

    <input type="radio" name="dashboard" value="dashboard1">1 <input type="radio" name="dashboard" value="dashboard2">2 <input type="radio" name="dashboard" value="dashboard3">3 <input type="radio" name="dashboard" value="dashboard4">4 <input type="radio" name="dashboard" value="dashboard5">5
    Is there a reason why you're not using CGI.pm to generate your form code?

    my %radio_field_values = ( 'dashboard1' => 1, 'dashboard2' => 2, 'dashboard3' => 3, 'dashboard4' => 4, 'dashboard5' => 5, ); print radio_group( -name => 'dashboard', -labels => \%radio_field_values, -values => [ keys %radio_field_values ], );