To a large extent, this is a follow-up to CGI: which field has changed?. I am trying to identify whether fields have changed. I have three menus, and am having no problem with them. But the text area is causing me problems. If I point my browser at the following code, the "Old" that appears above the text area is permanently zero length. At the end of the form, it is reported to contain text. This can be changed by editing the text area, unsurprisingly. But the value at the start of the code remains resolutely blank. I have tried using value instead of default, but the problem remains. I find it very strange that I should not get the same problem with the popup menus. I am running Losedows XP Pro, Apache 2.2.16, ActiveState 5.12.2, CGI 3.52 and FireFox 3.6.15.
Regards,
John Davies
use strict; use warnings; use lib qw(. lib); use CGI; use CGI qw/:standard -debug/; print_form(); sub print_form { print header; print start_html("Problem demo"); print "<h1>Problem demo</h1>\n"; print start_form; print "Old: " . param('OldBugText') . "<br>"; text_field(); print submit('Action', 'Submit'); print "</p>"; set_old_params(); show_vars(); print end_form; print "<hr>\n"; print end_html; } sub text_field { my $bugtext = "Example Text"; print "<p>", textarea(-name => 'BugText', -value => $bugtext, -rows => 10, -columns => 40); } sub show_vars { print "<h2>Here are the current settings in this form</h2>"; for my $key (param) { print "<strong>$key</strong> -> "; my @values = param($key); print join(", ",@values),"<br>\n"; } } sub set_old_params { for('BugText') { if (defined param($_)) { param(-name => "Old" . $_ , -value => param($_)); } else { param(-name => "Old" . $_ , -value => ''); } } }
In reply to CGI: retaining textarea contents in hidden field by davies
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |