CGI.pm dynamic parameters 
Author Message
 CGI.pm dynamic parameters

I'm having troubles pulling out parameters when I create them
dynamically. I have a for loop that creates a few fields

for (my $i = 0; $i < $number; $i++)
  {
   if ( ($i %2) == 0 ) { print "<tr bgcolor=\"#e5e5e5\">\n"; }
   else { print "<tr>\n"; }
    print qq!
        <td align="left"><input type="text" name="Serial$i"
size="10"></td><td>&nbsp;</td>
        <td align="left"><input type="text" name="Name$i"
size="25"></td><td>&nbsp;</td>
        <td align="left"><input type="text" name="Quantity$i"
size="5"></td><td>&nbsp;</td>
        <td align="left"><input type="text" name="Options$i"
size="20"></td><td>&nbsp;</td>
        </tr>
        !;
        $count++;
  }

when I try to pull these out in another for loop it doesn't take them

 $q->param ('Serial$i');

It's obviously something syntactical but I haven't been able to figure
it out. It works with $q->param ('Serial0');



Sat, 29 Jan 2005 03:57:16 GMT  
 CGI.pm dynamic parameters
Also sprach Ivan Dwyer:

Quote:
> I'm having troubles pulling out parameters when I create them
> dynamically. I have a for loop that creates a few fields

> for (my $i = 0; $i < $number; $i++)

Better:
  for my $i (0 .. $number - 1) {

Quote:
>   {
>    if ( ($i %2) == 0 ) { print "<tr bgcolor=\"#e5e5e5\">\n"; }
>    else { print "<tr>\n"; }
>     print qq!
>    <td align="left"><input type="text" name="Serial$i"
> size="10"></td><td>&nbsp;</td>
>    <td align="left"><input type="text" name="Name$i"
> size="25"></td><td>&nbsp;</td>
>    <td align="left"><input type="text" name="Quantity$i"
> size="5"></td><td>&nbsp;</td>
>    <td align="left"><input type="text" name="Options$i"
> size="20"></td><td>&nbsp;</td>
>    </tr>
>    !;
>    $count++;
>   }

> when I try to pull these out in another for loop it doesn't take them

>  $q->param ('Serial$i');

              ^        ^
Single quotes do not interpolate. Therefore:

   $q->param("Serial$i");

Tassilo
--

pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;



Sat, 29 Jan 2005 04:06:36 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CGI.pm - parameters duplicated in querystring and post input

2. CGI.pm parameter

3. CGI::Base.pm ** BUG**: https POST returns no parameters

4. Automatic arrays of imported parameters in CGI.pm?

5. CGI.pm - parameter count?

6. CGI.pm not parsing form parameters correctly

7. CGI.pm -labels parameter?

8. CGI.pm form parameters initialization question (probably silly)

9. CGI.pm /@arrayed parameters?

10. CGI.pm - parameters duplicated in querystring and post input

11. URI encoded parameter for CGI.pm problem.

12. CGI.pm query about passing parameters

 

 
Powered by phpBB® Forum Software