![]() |
|
The stupid question is the question not asked | |
PerlMonks |
Re: How to make a friendly UIby thraxil (Prior) |
on May 04, 2001 at 08:20 UTC ( #77869=note: 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:
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 // http://www.columbia.edu/~anders/ weblog // http://thraxil.dhs.org
In Section
Seekers of Perl Wisdom
|
|