in reply to Re: dynamically built form getting data parameters
in thread dynamically built form getting data parameters

Yes, that is exactly what I am attempting to do. Dealing with an array is what I am familiar with though I should read up on array references. How would I build an array of the data? Thanks for the path to wisdom hippo.
  • Comment on Re^2: dynamically built form getting data parameters

Replies are listed 'Best First'.
Re^3: dynamically built form getting data parameters
by tangent (Parson) on Jun 10, 2016 at 15:50 UTC
    The problem with multiple values in an array is that a checkbox field will not exist in the values sent by the form unless it is checked. In your example, if you kept the names the same and only one checkbox was ticked it would come in like this:
    Professor => ["Doe, Jane","Smith, Josh"], IDNum => ["0116411160645","0116411162016"], Status => "KEEP THIS ITEM",
    You have no way of telling which item this refers to. So you will need to group each item somehow, and I think your idea of incrementing is fine, as long as you do it to all parameters as hippo points out.

      Excellent point. The easy alternative is to replace the checkboxes with selects which just have "Yes" and "No" as options. Not as clean from a UI point of view, though.

      Yet another option is to set the values of the checkboxes to a unique identifier like the IDNum (assuming it is unique) and that way you know which ones are to be kept.

      There's also the JS option, but I like that least of all.

      TIMTOWTDI!

      Thanks everyone for the help and great information. The modules mentioned look promising, sadly they are not on installed on my system. Going to code it the long way as your right, I won't know which books have been checked.
Re^3: dynamically built form getting data parameters
by Marshall (Canon) on Jun 10, 2016 at 15:46 UTC
    You might find this helpful..Re: Pushing rows of data into array. Some examples of Array of Array and how to access them.

    Hope that helps.

    Also, you may find DBD::CSV of use. It is possible access a CSV file with SQL statements. Doesn't require and DB admin as the "database" is just a CSV file.

Re^3: dynamically built form getting data parameters
by hippo (Archbishop) on Jun 10, 2016 at 15:33 UTC

    OK, let's suppose you use CGI::Lite. Here's a simplistic script you might write to process any number of batches of fields:

    #!/usr/bin/perl -T use strict; use warnings; use CGI::Lite (); print "Content-type: text/plain\n\n"; my $cgi = CGI::Lite->new (); my $params = $cgi->parse_form_data; my $i = 0; while ($i <= $#{$params->{Professor}}) { print "Professor $i is $params->{Professor}->[$i]\n"; print "IDNum $i is $params->{IDNum}->[$i]\n"; # ... carry on with other fields here $i++; }

    Update: See also the get_multiple_values convenience method in the documentation which is a benefit if you don't know for sure that there will be more than one of each item.