First of all, what you are doing is Cargo Cult programming. Granted, a lot of us started that way, and some of us fall into that trap each time we meet an unfamiliar language/system/environment, but it leads to high blood pressure and hair loss. You should first try to understand WHY something is written the way it is, and only then try to write your own.

I don't know where you picked the "supposedly standard format", but it wouldn't run in any JavaScript I ever came across. I don't even see the purpose of doing it that way: after all, if you want to display a form with empty fields, just print it that way.

But in the hope that it might do some good to you and others who might run across this article, let me write something about setting fields in HTML forms in general.

There are several options:

None of that options can be said to be Best option for all occasions. Each option involves compromises. The easier it is to implement, the slower it will likely be once it is deployed. But even HTML::FillInForm, which parses the HTML each time it displays it, is plenty fast for most applications.

And hopefully, by the time you graduate to writing scripts that need to run on a hundred-requests-per-second production server, you will have developed a feeling of when programmer convenience needs to be sacrificed to the goods of speed, and when programmer's time is better spent doing other things.


In reply to Re: resetting form values by matija
in thread resetting form values by pmachin

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.