Contributed by lauragarcia
on Apr 25, 2001 at 21:46 UTC
Q&A
> input and output
Description: I have set up a textarea form on my site that will enable authors to submit their written contributions to a mySQL database. How can I make it possible for these guys and gals, if they have rewrites/updates of texts that they have already submitted, to go back and redisplay the form with the information they filled in previously so that all they have to do is institute their changes and resubmit?
Answer: How to redisplay previously submitted text contributed by merlyn If you're using the CGI.pm shortcuts (and why shouldn't you?), you can set the default value using the param method:
use CGI qw/:all/;
...
my $previous_value = "This is what I wrote before"; # fetch this someh
+ow
param('story', $previous_value); # sets default to previous
...
print textarea('story'); # prints an input form element, defaulting to
+ previous value for it
| Answer: How to redisplay previously submitted text contributed by arturo look at the value attribute for text input tags => print "<input type='text' name='bar' value='$bar'>\n";, where $bar is a perl variable containing the value from the DB. Be sure to escape quotes, or risk producing broken HTML. For textareas, all you need to do is put the value in between the opening and closing tag, like so:
<textarea name="foo" rows=5 cols=80>
$foo</textarea>
|
Please (register and) log in if you wish to add an answer
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|