in reply to Re: Passing Data
in thread Passing Data

Hi.... The first bit of code is the form that the user enters the information.
sub get_product_table { my $sth = shift; my @row; while (my $ref = $sth->fetchrow_hashref ()) { # generate a form allowing a quantity of the item to be added # to the cart push (@row, start_form(-method=>'GET', -action=>url()), hidden( -name => "choice", -override => 1, -default => "add" ), hidden( -name => "item_id", -override => 1, -default => escapeHTML( $ref->{item_id} )), Tr ( td ( escapeHTML( $ref->{item_id} )), td ( escapeHTML( $ref->{description} )), td ( { -align => "right" }, escapeHTML( sprintf( "%.2f", $ref->{pri +ce}))), td ( "" ), td ( textfield( -name => "quantity", -size => "2")), td (image_button( -name => "Add Item", -src=>"../images/add.jpg", - +border=>"0" ))), end_form() ); } $sth->finish (); return undef unless @row; # no items? unshift (@row, Tr ( # put header row at beginning th ("Item"), th ("Description"), th ("P +rice"), th ("" +), th ("Q +ty"), )); return (table ({-border => 0, -align => "center"}, @row)); }
The next bit of code is the next form that reads the inputted data and allows the user to make changes.
push (@row, start_form(-method=>'GET', -action=>url()), hidden( -name => "choice", -override => 1, -default => "update" ), hidden( -name => "item_id", -override => 1, -default => escapeHTML( $i +tem_id )), Tr ( td ( escapeHTML( $item_id )), td ( textfield( -name => "quantity", -s +ize => "2")), td (escapeHTML ($item_ref->{description})), td ({-align => "right"}, escapeHTML (sprintf ("%.2f", $item_ref->{price +}))), td ({-align => "right"}, escapeHTML (sprintf ("%.2f", $total_item_price +))), + ($show_links ? td (a ({-href => $url}, img ({-src => "../im +ages/delete.jpg", -border => "0"}))) + : td (" ")), end_form()
If you need more info, let me know. Thanks.

Replies are listed 'Best First'.
Re: Re: Re: Passing Data
by poj (Abbot) on Jan 25, 2003 at 19:38 UTC
    It's hard to sort this out without seeing all the code but at a guess I would first look at where you have this in the first script
    hidden( -name => "item_id", -override => 1, -default => escapeHTML( $ref->{item_id} )),
    and this is the secomd
    hidden( -name => "item_id", -override => 1, -default => escapeHTML( $item_id )),
    and in particular, check the scope of $item_id
    poj
      Hi, You can view my scratchpad for the whole code. Thanks.