Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Dynamic table problem

[b][red]This message was edited by davidrtg at 2003-11-7 8:9:55[/red][/b][hr]
[b][red]This message was edited by davidrtg at 2003-11-7 8:7:47[/red][/b][hr]
I'm trying to create a dynamic table that will add more rows every time you press the "Add Rows" button.
The way i'm going at it is like this.
[code]
&addPartRows;
if ($form{'addmoreparts'} eq 1)
{
$partsrows += 1;
&addPartRows;
}
[/code]
[code]
sub addPartRows
{
print <<"EOF";
<tr>





EOF
$prownum += 1;

$pcount = 0;
while ( $pcount < $partsrows ) {
print <<"EOF";
<tr>





EOF
$prownum += 1;
$pcount += 1;

}
}
[/code]
It calls the addPartsRows sub which builds the first row. If you click on the "addmoreparts" button it adds one to $partsrows then prints out the main row plus another row untill $pcount is equal to $partsrows. So if they have clicked on the button 5 times it should have added 1 to $partsrows 5 times and should print out 5 times but it doesn't.

The code only runs correctly once. After the first time clicking the add button it reloads the same page and doesn't increment $partsrows past 1.

EDIT: To me it seems that the scalars aren't holding thier values and get reset each time I click the button. Now that I think about it am I going to have to pass their values with the form? Gonna go see if that works =)

EDIT: Yup, that was it!! Horray!! heh

David




Sign In or Register to comment.