I do that quite often myself. I have a rather complex Intranet Web site. I generate a lot of JavaScript from my Perl code.

The trick is to know what should be done by JavaScript. And then starts the old and true mantra...

"Never trust a users input data."

The users input data is no more trustworthy because it's been mangled by JavaScript. The JavaScript code can be executed completely under the users control.

OTOH, JavaScript can be very helpful to show the user how to navigate the site, how to fill in the data entry fields, giving dynamic help and hints depending upon already chosen options or data entered in key fields.

The important thing to remember is that when the data is sent up to the server, it must be verified a second time. And that the server script is the ruling body. If the JavaScript approved the data but the server side script doesn't, then the JavaScript is wrong.

JavaScript has been given a bad reputation. I believe this is because JavaScript has been used for things it definitively should not be used for. It's supposed to be a help for the user, think user interface, not to be part of the data processing software.


Everything went worng, just as foreseen.


In reply to Re: Generating JavaScript from Perl (article in DDJ) by Biker
in thread Generating JavaScript from Perl (article in DDJ) by runrig

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.