rekha Posted March 19, 2008 Share Posted March 19, 2008 Hi I want to call two js functions using one submit button.I have tried the below code.But it gives error. <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 one is not defined. But i am getting All as output. Pls anybody solve this .... Regards Rekha Quote Link to comment https://forums.phpfreaks.com/topic/96867-calling-two-js-functions-using-one-submit-button/ Share on other sites More sharing options...
haku Posted March 19, 2008 Share Posted March 19, 2008 <script type="text/javascript"> function one() { document.write("hai") } function two() { document.write("All") } function wrapper() { one() two() } </script> <form> <input type=button value="ok" onClick="wrapper()" > </form> Quote Link to comment https://forums.phpfreaks.com/topic/96867-calling-two-js-functions-using-one-submit-button/#findComment-495701 Share on other sites More sharing options...
rekha Posted March 19, 2008 Author Share Posted March 19, 2008 Hi I want to call the two functions like this onClick="two();one()" Regards Rekha http://hiox.org Quote Link to comment https://forums.phpfreaks.com/topic/96867-calling-two-js-functions-using-one-submit-button/#findComment-495735 Share on other sites More sharing options...
haku Posted March 19, 2008 Share Posted March 19, 2008 You cant do it like that. You already tried and it didn't work. So I told you how to do it. Look at what I posted, and do that. Quote Link to comment https://forums.phpfreaks.com/topic/96867-calling-two-js-functions-using-one-submit-button/#findComment-495817 Share on other sites More sharing options...
fenway Posted March 19, 2008 Share Posted March 19, 2008 You cant do it like that. You already tried and it didn't work. So I told you how to do it. Look at what I posted, and do that. There's nothing wrong with calling multiple functions in an event handler -- as long as none of them return. Quote Link to comment https://forums.phpfreaks.com/topic/96867-calling-two-js-functions-using-one-submit-button/#findComment-495888 Share on other sites More sharing options...
haku Posted March 20, 2008 Share Posted March 20, 2008 oh You live you learn! haha Quote Link to comment https://forums.phpfreaks.com/topic/96867-calling-two-js-functions-using-one-submit-button/#findComment-496456 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.