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

Hi! I have a cgi script in which I have a table with more rows and columns! At the beginning of each row i have a checkbox and when I check it I want to read the entire row and print it. Here is the code with the table:
print "<form method=\"post\" name=\"Fsubmit\" action=\"submit.cgi\">"; print "<br><br><center><table border=2>"; print "<th>Select</th><th>Field</th><th>Phase</th><th>Serverside</th>< +th>Statereaction</th><th>Productionon</th><th>Releaseproductsoff</th> +<th>onProjects</th><th>Deadlineok</th>"; foreach (@a){ print "<tr><td><input type=\"checkbox\" name=\"check\" ></td><td>$a[$_ +]></td><td>$b[$_]</td><td>$c[$_]</td><td>$d[$_]</td><td>$e[$_]</td><t +d>$f[$_]</td><td>$g[$_]</td><td>$h[$_]</td></tr>"; } print "</table>"; print "<INPUT TYPE=\"submit\" VALUE=\"OK\">";
My problem is that i have no idea how to create submit.cgi so that i can read and print the entire row selected. Of course can be more then 1 row selected. I hope you understand me. Thank you for your time.

Replies are listed 'Best First'.
Re: How do I read a checkbox from a CGI
by jeffa (Bishop) on Sep 29, 2003 at 14:19 UTC
    We understand you, but do you understand HTML? The HTML you have is wounded at best, and i can tell by the way you generate it that you are new at this game. I suggest that you first do some studying on HTML forms and tables before you attempt CGI scripting. Where are you getting the data from? What are these arrays that you have and why are they not in an array themselves?

    In the meantime, why not learn some good Perl/CGI techniques over at Ovid's free online Web Programming with Perl course? It don't cost nuthin' ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: How do I read a checkbox from a CGI
by jasonk (Parson) on Sep 29, 2003 at 14:17 UTC

    All the CGI is going to get from the browser is whether the checkbox is checked or not, you need to keep track of the data to display yourself. Assuming the arrays you are displaying are available in the submit.cgi as well, you could change your checkbox to something like:

    <input type="checkbox" name="check" value="$_">

    Then in submit.cgi you can check which boxes were checked:

    my $cgi = new CGI; foreach($cgi->param('check')) { print "<tr><td>$a[$_]</td><td>$b[$_]</td>....</tr>\n"; }

    We're not surrounded, we're in a target-rich environment!
Re: How do I read a checkbox from a CGI
by kutsu (Priest) on Sep 29, 2003 at 16:09 UTC

    READ jeffa's post first but:

    <tr> <td align="right">Description of Checkbox</td> <td align="right"><input type="radio" name="foobar" value="0 +" checked> </td> <td colspan="6"><b>No preference.</b></td> </tr>

    And call it with:

    my $foobar = param('foobar'); die "Invalid datatype for foobar" if $foobar =~ /[^0-9]/; print "checked\n" if $foobar == 0;

    "Pain is weakness leaving the body, I find myself in pain everyday" -me