Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Web Design, HTML And CSS Forums (http://www.go4expert.com/forums/web-design-forum/)
-   -   calling two js functions using one submit button (http://www.go4expert.com/forums/calling-js-functions-using-submit-button-t9453/)

rekha 19Mar2008 12:52

calling two js functions using one submit button
 
Hi

I want to call two js functions using one submit button.I have tried the below code.But it gives error.

Code:

<script language=javascript>
function one()
{
document.write("hai");
}
function two()
{
document.write("All");
}
</script>
<form>
<input type=button value="ok" onClick="two();one()" >
</form>

I got the error as

Code:

one is not defined.
But i am getting All as output.

Pls anybody solve this ....

Regards
Rekha

pradeep 22Mar2008 11:20

Re: calling two js functions using one submit button
 
Try this
Code: HTML

<script language=javascript>
function one()
{
document.write("hai");
}
function two()
{
document.write("All");
}

function a()
{
    two();
    one();
}   
</script>
<form>
<input type=button value="ok" onClick="a();" >
</form>


rekha 24Mar2008 09:41

Re: calling two js functions using one submit button
 
Hi Pradeep,

I want to call the function as i have in the above example that i have given.What is the error in it?


Regards
Rekha

pradeep 24Mar2008 10:10

Re: calling two js functions using one submit button
 
HTML Code:

<script language=javascript>
function one()
{
alert("hai");
}
function two()
{
alert("All");
}
</script>
<form>
<input type=button value="ok" onClick="two();one()" >
</form>

But your version doesn't work because you are using document.write, after calling the first function the document is overwritte, so, it can't find function one().


All times are GMT +5.5. The time now is 06:05.