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. |