Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Button calling multiple functions

Reply
Thread Tools

Button calling multiple functions

 
 
allanrodkin@hotmail.com
Guest
Posts: n/a
 
      08-23-2005
Hi,

I am a newbie. I am programming in Perl and dynamically generating
html. I want to call two functions on the click of a button, one a
javascript function and also a Perl function. Is there a way to do
this. So far I am using the following code but I don't know how to
include a call to a second function in the tag

$html .= qq`\n<input type=button value="deletestyle" name=
"deletestyle"
onclick="JavaScript:do_deletestyle()">`;

Thanks,
Fred

 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      08-23-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> I am a newbie. I am programming in Perl and dynamically generating
> html. I want to call two functions on the click of a button, one a
> javascript function and also a Perl function.


Perl almost always runs on the server, JavaScript almost always runs on the
client.

So you would /probably/ do something like:

<form action="myPerlScript.pl" onsubmit="someJavaScriptFunction()">
<div>
<input type="submit">
</div>
</form>

OR

You would have your Perl script output something along the lines of:

<script type="text/javascript">
someJavaScriptFunction();
</script>

.... depending on what data needed to be sent to the Perl script and what
order you wished the JavaScript function and Perl subroutine to run in.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
 
allanrodkin@hotmail.com
Guest
Posts: n/a
 
      08-23-2005
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

 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      08-24-2005
(E-Mail Removed) 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>

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
Benjamin Niemann
Guest
Posts: n/a
 
      08-24-2005
Jonathan N. Little wrote:

> (E-Mail Removed) 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/
 
Reply With Quote
 
Hilarion
Guest
Posts: n/a
 
      08-24-2005
>>> 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?
>>>

>> 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).



For this to work you'll have to change onsubmit="someJavaScriptFunction()"
to onsubmit="return someJavaScriptFunction()".


Hilarion

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variadic functions calling variadic functions with the argument list, HLL bit shifts on LE processors Ross A. Finlayson C Programming 19 03-10-2005 03:57 AM
Function pointers, variable argument functions calling other variable-argument functions (sort of) S?ren Gammelmark C Programming 1 01-07-2005 09:41 PM
Server Side button calling page_load before calling it's own click event. Ryan Ternier ASP .Net 4 07-29-2004 01:06 PM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM
External inline functions calling internal inline functions Daniel Vallstrom C Programming 2 11-21-2003 01:57 PM



Advertisments