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

Hi,

I am sorry to bother everyone but im in a bit of a muddle. I have looked everywhere (including perl monks) for the answer (and found one that i thought might work on perl monks but i couldn't make it work).

My problem is that i am making a small web library (books, Dvd's) with a flat file database for a project and i have come to a problem that has stumped me.

I need to have my script generate a dynamic form with option buttons for however many records were added (this i have done by just looping a table with sequential record Id no.s for the option button values). I then need to set these option buttons and recieve them in another form.

My question is (sorry it took so long) how do i recieve the inputs in the next script if i dont know how many different fields im going to have?

I understand (read it in perl monks and tried it) that i can read teh inputs to an array and but i could not make it work.

These inputs are all for the same field by the way. id much appreciate some help.

here is what i have so far

#!/usr/local/bin/perl -w # loanType.pl # library script to set the loan types of the records require "cgi-lib.pl"; print &PrintHeader; print "<HTML><HEAD><TITLE>Library Admin Screen</TITLE> <LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"library.css\"></ +HEAD> <BODY BGCOLOR=\"#336699\">"; #parse form &ReadParse(*input); #from form $action = $input{'action'}; $itemId = $input{'itemId'}; $firstId = $input{'first'}; $lastId = $input{'last'}; $tempIdStorer = $firstId; for ($firstId..$lastId) { @loanType = $input{'$firstId'}; $i++; } #####rest of my code to alter the records etc.

id really, really appreciate any help anyone can give me

Replies are listed 'Best First'.
Re: dynamic form inputs
by rinceWind (Monsignor) on Apr 11, 2002 at 20:57 UTC
    Hi welshy,

    What version of perl are you running? I recommend that if you are running one <= 5.004, upgrade to the latest, which comes with CGI.pm - which totally replaces cgi-lib.pl.

    CGI.pm allows you to have multiple list items accessable via an array, and the whole thing is also much more secure and robust. The documentation on CGI.pm, see this is quite comprehensive, and Super Search will give you pointers to much correspondence on how to use this module.

    Welcome to the 21st century.

Re: dynamic form inputs
by gav^ (Curate) on Apr 11, 2002 at 20:48 UTC
    You might find it helpful to use CGI.pm instead of the very outdated cgi-lib. See also use CGI or die.

    gav^

Re: dynamic form inputs
by XeneX (Initiate) on Apr 12, 2002 at 01:45 UTC
    Add a counter to your first script that generates the form. Count how many records you're adding, then pass that value along using an input TYPE=HIDDEN field in the form. Then you can loop as many times as the counter value to receive all of the option buttons.
      thanks very much for all your help...ill give these suggestions a try. ill even begin to use CGI.pm (lecturers at uni taught us how to use cgi-lib - i did wonder why I was the only one using cgi-lib !!!). cheers welshy.