Topic: call more than one function

hi,

can we call more than one function from single event in javascript if yes than how plz tell me

[code=Javacript]

<input type="button" onclick="aim()" value="Display alert box" />

[/code]

Re: call more than one function

hi.

you can wink

[code=Javacript]
function aim(){
    f1();
    f2();
return whatever;
}
[/code]


pzdr halski103

Re: call more than one function

I have used this technique, and it works ok apart from 1 important thing.

Suppose f1(); is a call to a xajax-routine which inserts a record in a database.
Suppose f2(); is a call to a xajax-routine which displays the records.

Sometimes the newly inserted record is not displayed by f2();
I've used firebug to investigate the problem.
It looks like a multi-threading problem to me. Sometimes f2(); is finished earlier than f1();
So, display the records first, *before* the insert...

Any suggestions?


function aim(){

    f1();

    f2();

return whatever;

}

4 (edited by rizla_za 2009-06-14 10:01:35 AM)

Re: call more than one function

Maybe by adding a delay will solve your problem.

function aim() { 

 f1(); 
 setTimeout( "f2();", 5000); 

return whatever;
} 

where 5000 = 5sec

Re: call more than one function

mr_gupta wrote:

hi,

can we call more than one function from single event in javascript if yes than how plz tell me

</p><div class="codebox"><div class="incqbox"><h4>Code: Javacript</h4><div><div style="font-family: 'Courier New';font-size:10pt" dir="ltr"><div class="javacript" style="font-family:monospace;"><br />
&nbsp;<br />
&lt;input type=&quot;button&quot; onclick=&quot;aim()&quot; value=&quot;Display alert box&quot; /&gt;<br />
<br />
&nbsp;</div></div></div></div></div><p>


if you mean call the two funcs with the onclick event you may use this:

<input type="button" onclick="aim(); aim2();" value="Display alert box" />

if you're triying to use a confirmation...

<input type="button" onclick="if(confirm('Are you sure?'))  aim();return false;" value="Display alert box" />

Re: call more than one function

If you agree, can we call more than one function from single step in javaScript and if yes tell me please.