You are here: Re: Button calling multiple functions « HTML « IT news, forums, messages
Re: Button calling multiple functions

Posted by Benjamin Niemann on 08/24/05 11:37

Jonathan N. Little wrote:

> allanrodkin@hotmail.com wrote:
>> Hi Mr. Dorward,
>> I have a couple questions about the first solution you gave.
>>
>> <form action="myPerlScript.pl" onsubmit="someJavaScriptFuncti­on()">
>> <div>
>> <input type="submit">
>> </div>
>> </form>
>>
>> Forgive me for my ignorance in this matter. Using this code, I'm
>> assuming the JavaScript function executes first. If so, how do you
>> return the values you want from the JavaScript function so I can send
>> them to the perl script?
>>
>>
>> Thanks,
>> Fred
>>
> If it is a posting to a form, then have some input fields, usually
> 'hidden' for this purpose that the JavaScript sets their value before
> submition of the form.
>
> <script type="text/javascript">
> function someJavaScriptFunction(){
> var f=document.forms[0];
> ...
> f.toBeSet.value="Some Value Derived by JavaScript";
> ...
> return true;
> }
> </script>
>
> ...
>
> <form action="myPerlScript.pl" onsubmit="someJavaScriptFunction()>
> <input type="hidden" name="toBeSet">
> ...
> </form>
>

Also note that the return value of JS function (always 'true' in the example
above) determines, if the form will actually be submitted (and if your perl
script on the server will be executed). Returning 'false' will prevent the
form submission (but you can't stop non-JS users from submitting the form
of course).

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация