in reply to Re^2: perl + cgi - onclick generation problem
in thread perl + cgi - onclick generation problem

But how to set the incremented value in the same hidden field (...) The only way I know to set a value for hidden_field is while creating

Well, you are creating the field anew for every page view, anyway (if we're talking about the non-javascript variant, that is), so just set the value as you did the first time...

Or, in case you're using CGI for HTML generation, too (not just for parameter parsing), you can modify the (otherwise sticky) value with:

$cgi->param('hidden_field', 'new value');

Replies are listed 'Best First'.
Re^4: perl + cgi - onclick generation problem
by matrixmadhan (Beadle) on Dec 12, 2008 at 10:26 UTC
    I simply ran out of idea and cannot proceed further
    This is the code snippet what I had tried and it never works the way as expected
    sub hidden_field { my $counter = $cgi->param('field_1'); if ( not defined $counter ) { $counter = 1; } else { $counter++; } print $cgi->hidden('field_1', $counter); return $counter; } my $count = hidden_field; foreach ( 1 .. $count ) { #here is a seperate function that generates set of 3 text_area }
    Any pointers please?
      I got it :)
      print $cgi->hidden( -name => $field_name, -default => $field_data, -override => 1 );
      This is what I want and its working now as expected.
      Thanks for all the help offered :)