473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to call multiple functions using a button

hai,

I have 2 javascript funtions.I want to call these 2 functions using one button.

my code is like this,

[html]
<input type="button" value="ok" onclick="validate(this),change()">
[/html]

It is working.But after executing the first function its automatically goes to the second function.Within the first function i have displayed some messages using innerhtml and also it returns false. The messages are also displayed but the second function also executing.The control automatically goes to the next page.

Can enybody please help me.
Aug 14 '07 #1
3 3547
Logician
210 100+
hai,

I have 2 javascript funtions.I want to call these 2 functions using one button.

my code is like this,

[code:html]
<input type="button" value="ok" onclick="validate(this),change()">
[/code:html]

It is working.But after executing the first function its automatically goes to the second function.Within the first function i have displayed some messages using innerhtml and also it returns false. The messages are also displayed but the second function also executing.The control automatically goes to the next page.
Presumably you mean that you want to execute the second function only when the first returns true.
You haven't shown what change does, but if it could return true either on 'success' or always, then you could use:
Expand|Select|Wrap|Line Numbers
  1. onclick="return(validate(this) && change())"
Aug 14 '07 #2
misaw
17
hai,

I have 2 javascript funtions.I want to call these 2 functions using one button.

my code is like this,

[html]
<input type="button" value="ok" onclick="validate(this),change()">
[/html]

It is working.But after executing the first function its automatically goes to the second function.Within the first function i have displayed some messages using innerhtml and also it returns false. The messages are also displayed but the second function also executing.The control automatically goes to the next page.

Can enybody please help me.
What i understand is 2nd function conditionally executed if first returns true
else do not want to run 2nd function which changes the page...

to do this

Expand|Select|Wrap|Line Numbers
  1. <input type="button" value="ok" onclick="OnClickCall(this)">
  2.  
  3. function OnClickCall(obj){
  4.  if(validate(obj)){
  5.   change();
  6.  }
  7. }
  8.  
Aug 15 '07 #3
acoder
16,027 Expert Mod 8TB
Thanks everybody for using code tags. Shame that it didn't quite turn out right.

To use them properly, use [ CODE=javascript] (without the space) and substitute the language of your choice, e.g. html, php. Close them with [/code]. Thanks!
Aug 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: charlie fortune | last post by:
I want to make a database script with several functions, such as adding entries, amending, listing etc. I know how to make a submit button call a php script, but not particular functions within...
5
by: Anand Ganesh | last post by:
Hi All, I need some help. I am sort of not sure how to approach this problem. I have a MAINPROGRAM. This is the core application. I have asked two of my staff to developed two different...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
6
by: Radith Silva | last post by:
Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click If txtName.Text <> "" Then If txtUnits.Text <> "" Then If optOne.Checked Or...
22
by: Ricky W. Hunt | last post by:
First, the subject probably doesn't use the correct terms but I'm not sure what it's called in VB. I'm writing a media player app. The subroutine that handles the "open file" button contains an...
13
LacrosseB0ss
by: LacrosseB0ss | last post by:
I was wondering, can an OnClick event of a button call multiple functions? The reason for this is I have a page that when "ok" is clicked, goes to a preview page before submitting data to the...
46
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.