It is important to understand that Perl works on the server side, and JavaScript works in the user’s browser. That these two might be on the same computer, does not matter.

JavaScript can only mangle the HTML, the DOM of the web page — its changes are local to the browser, and by default, there’s nothing more to it.

The server (a web server with a Perl application interpreting the requests in this case) only knows about HTTP requests being made to it. The only time the Perl script runs, is when there’s an HTTP request being made by the user.

This brings us to, thus: On the client side, you use JavaScript to prepare values in form fields, use either JavaScript or the user clicking on the submit button to submit the form — the browser makes an HTTP request to the server with the appropriate form data added, and then the Perl script can deal with any kind of form fields (variables) it received.

Long story short: to get the JS variable cb to be in the Perl variable $cb you need to submit its value as the value of a form item (named anything, really), and then put the value of said form field into the Perl variable.


In reply to Re: Perl Mason2 jquery get the value of a checkbox by Ralesk
in thread Perl Mason2 jquery get the value of a checkbox by Anonymous Monk

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.