in reply to Re^4: Passing perl variable as input name?
in thread Passing perl variable as input name?
First - you need to fix how you fech the param value - at the time the form' s values are being collected, $unit_name does not exist - so you need to do:
Next, you need to create a single hidden field OUTSIDE the loop:my $selectedName = param('unit_name');
Next, your loop should look something like this:print "<input type='hidden' name='unit_name' value='This gets set via + javascript'>";
print "<td>\n"; # If you want all buttons in a single TD .. otherw +ise, this could be <tr> while (my @data = $sth->fetchrow_array()) { $unit_name = $data[0]; push(@unitNames, $unit_name); print "$unit_name<br>"; print "<input type='image' name='$unit_name' id='$unit_name' a +lt=airConButton src='../../images/unit.jpg' height='100px' width='100px' onclick='this.form.unit_name.va +lue =\"$unit_name\";this.form.submit()'></input>"; } # Close the TD or TR here..
"Software interprets lawyers as damage, and routes around them" - Larry Wall
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Passing perl variable as input name?
by RobRobson (Novice) on Jul 22, 2016 at 14:30 UTC |