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

Dear Perl Monks,

I have a html table as follows
1. Name1|Age1|Position1 checkbox 2. Name2|Age2|Position2 checkbox 3. Name3|Age2|Position3 checkbox <disp button>
when i press the <disp button>, only those rows whose checkbox were selected should be displayed in the next page. please guide me how to do it in cgi-perl. my present code displays only the checkbox value
my @cb = param('disp'); foreach my $cb (@cb) { print "You picked $cb.<br>\n"; }
where 'disp' is the value of the checkbox in the html form.

pls let me know how to display the entire row.

Replies are listed 'Best First'.
Re: Extracting data from a form
by davorg (Chancellor) on Mar 07, 2006 at 09:59 UTC

    Difficult to know more without more details about what are going on. We need to know where the rest of the data that you are displayed is stored. Here are three possibilities that I can think of.

    1. You're displaying data that is stored in a database. Then make the values of the 'disp' checkboxes the primary key of the database rows. Only select and display the IDs that have been chosen.
    2. You're displaying data that is stored in a text file. Then make the values of the 'disp' checkboxes the row number in the text file. Only display the data from the chosen rows.
    3. You're displaying data that is input on the form. Then you need to name the input fields in some way based on the values in the 'disp' checkboxes so that you can access the data that you want to display.
    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Extracting data from a form
by pajout (Curate) on Mar 07, 2006 at 09:57 UTC
    There are many ways how to do it, it very depends, what you need. You can, for instance, build the table dynamically on the server-side and include the checked rows only. This is, in my opinion, good solution. Or, you can do some tricks with javascript on the client-side - you can optically hide not checked rows when page is loaded. This solution is dirty, but it gives potentiality to show not checked rows without requesting the server.