http://www.perlmonks.org?node_id=174315


in reply to Increment Number with form button push

You are never updating the variable to be carried over. First, $add_limit is unecessary, just do this instead:
my $limit_3 = param("limit_3"); my $limit = param("limit"); $limit = ($limit_3 + $limit); print $limit; # and rest of form
Now, when you write out the hidden field, it will contain the current value. Before, you were writing out $limit to the hidden field without changing it's initial value, which was always 0.

Here is some more code to meditate upon:

use strict; use CGI qw(:standard); my $i = param('hidden_i') || 0; my @view = qw( first second third fourth fifth sixth seventh eighth ); my $view = $view[$i++]; param('hidden_i',$i % @view); print header, start_html('hidden fields'), h1($view), start_form, hidden('hidden_i'), submit, end_form, end_html, ;

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: Increment Number with form button push
by peppiv (Curate) on Jun 13, 2002 at 20:11 UTC
    Ah Yes! This works!
    If I wasn't having such a brain fart I'd write something clever.

    Thanx

    peppiv