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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.