Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

How to redisplay previously submitted text

by lauragarcia (Acolyte)
on Apr 25, 2001 at 21:46 UTC ( #75552=categorized question: print w/replies, xml ) Need Help??
Contributed by lauragarcia on Apr 25, 2001 at 21:46 UTC
Q&A  > input and output


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 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!
  • 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, 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
  • 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (4)
    As of 2020-09-19 12:21 GMT
    Find Nodes?
      Voting Booth?
      If at first I donít succeed, I Ö

      Results (114 votes). Check out past polls.