Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
"Is it possible to call a perl function from onChange? or is it possible to call a perl function from within a javascript function or is there a completely different way to do this that I havn't thought of?"

you "call" a cgi script by sending an HTTP request. so you can't really call a specific perl function directly from javascript. the best you can do is put whatever functionality you wanted from the function into its own perl script and send requests for that.

normally, if your browser sends an HTTP request, it will load the page it gets as a response into the browser, replacing the current page. you can get around this by having your perl script send back non-parsed headers. (see the documentation for the CGI module for info on how to do that). the other option is the hidden frame trick mentioned earlier.

on the javascript end of things, you'd want to have it change the url of the current document to the url of the nph perl script, plus as many fields as necessary passed as GET variables.

ie, you'd probably have something similar to:

<input type="text" name="foo" onblur="updateField("foo",this.value)" />

where the javascript function updateField has been defined as something like:

function updateField(field,value) { var newurl = " +d=" + field + "&value=" + value; document.location.href = newurl; }

this is all off the top of my head, so there are probably some things i forgot. obviously, you would also need to pass along something akin to the primary key for the record so the script knows which one to update. plus you'd have to be careful to url encode everything you pass in the url, etc, etc.

all in all, the benefit probably isn't worth the work it would take to get it all to work.

anders pearson // digital samurai
personal/pgp  //  
weblog       //

In reply to Re: How to make a friendly UI by thraxil
in thread How to make a friendly UI by daveh71

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2023-09-30 22:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found