Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

How to redisplay previously submitted text

( #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


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:
    & &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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2014-09-01 23:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (18 votes), past polls