473,608 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can OnClick call multiple functions?

LacrosseB0ss
113 New Member
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 database. If "Modify" is clicked, I want to change session variables (using VB) and then go to the previous page (the easiest way I know how to do this is history.go(-1) in js).

Can OnClick call both functions? Or is there a way to do this in only VB or JS?

TIA
- LB
Nov 30 '06 #1
13 107505
AricC
1,892 Recognized Expert Top Contributor
I think the easiest way would be make 2 functions then a 3 that will decide which of the 2 it wants to call.
Nov 30 '06 #2
LacrosseB0ss
113 New Member
The reason I wanted to do it this way was because I want to use Javascript code as well as VB code. The VB will change session variables and the JS will change the page.

I have since tried using VB and in the Page_Load method saying
Expand|Select|Wrap|Line Numbers
  1. Dim prevPageURL As String = Page.PreviousPage.ToString
  2. cmdModifyForm.Attributes.Add("PostBackUrl", prevPageURL)
  3.  
and then doing the session variables in cmdModifyForm_C lick. We'll see how that goes.

Thanks again
- LB
Nov 30 '06 #3
steven
143 New Member
You can just call a single function with the onclick, then this will call 2 other function.

Expand|Select|Wrap|Line Numbers
  1. <button onclick="javascript: funcCaller();" value="press me" />
  2.  
  3. <script type="text/javascript">
  4.  
  5. function funcCaller() {
  6.   funcOne();
  7.   funcTwo();
  8. }
  9.  
  10. ...
  11.  
  12. </script>
Dec 1 '06 #4
Joe Lay
3 New Member
Above code simply call 2 functions at the same time. I just want to know how to call functions like ELSE IF . if 1 function check finished , another to call


regards
Feb 26 '07 #5
iam_clint
1,208 Recognized Expert Top Contributor
<input type="button" onclick="functi on1(); function2(); function3(); function4(); function5();">
Feb 26 '07 #6
Joe Lay
3 New Member
i mean it's run all functions at the same time. i just want to run 1st function first. if the 1st function is OK, the second function to work.

Example is that ----
_______________ _______________ _______________ _______________ _____
function formcheck(){
if (usr==""){
alert ("Please provide User Name");
frm.usrid.focus ();
}
}

function numcheck(){

var NumExpression=/^[0-9]+$/;
if (!document.frm. scode.value.mat ch(NumExpressio n)){
alert("Invalid, Number Only");
frm.scode.selec t();
return false;
}

}

<input type="button" value="submit" onclick ="formcheck( ); numcheck();">
_______________ _______________ _______________ _______________ ____

so if i write like above state, it run all the alert messages. i just want to run formcheck() function first. if it is OK and no more blank " " in Text box , User will click Submit button, then the second numcheck() function will work.
I don't want to put 2 Submit button. That's the problem.
so~~~

How can i call function correctly ? Any1 please
Feb 26 '07 #7
AricC
1,892 Recognized Expert Top Contributor
i mean it's run all functions at the same time. i just want to run 1st function first. if the 1st function is OK, the second function to work.

Example is that ----
_______________ _______________ _______________ _______________ _____
function formcheck(){
if (usr==""){
alert ("Please provide User Name");
frm.usrid.focus ();
}
}

function numcheck(){

var NumExpression=/^[0-9]+$/;
if (!document.frm. scode.value.mat ch(NumExpressio n)){
alert("Invalid, Number Only");
frm.scode.selec t();
return false;
}

}

<input type="button" value="submit" onclick ="formcheck( ); numcheck();">
_______________ _______________ _______________ _______________ ____

so if i write like above state, it run all the alert messages. i just want to run formcheck() function first. if it is OK and no more blank " " in Text box , User will click Submit button, then the second numcheck() function will work.
I don't want to put 2 Submit button. That's the problem.
so~~~

How can i call function correctly ? Any1 please
Add a boolean var blnIsValid = true then set it to false anytime something doesn't go right at the end check that the variable is true if so go to function 2 if not go back to function 1.
Feb 26 '07 #8
Joe Lay
3 New Member
Add a boolean var blnIsValid = true then set it to false anytime something doesn't go right at the end check that the variable is true if so go to function 2 if not go back to function 1.

Please show me example codes or program...
Feb 28 '07 #9
acoder
16,027 Recognized Expert Moderator MVP
Please show me example codes or program...
I assume you want something that shows an alert if there is a problem by going through the functions. You don't need the user to press the submit button again if the first validation passed.

Just include all your functions in one formCheck function. Then this function can call all the functions one by one. Whenever a function 'fails' (meaning there is an error), just return false, otherwise it continues on till the end:
Expand|Select|Wrap|Line Numbers
  1. function formCheck {
  2. if (!numCheck()) return false;
  3. if (!emailCheck()) return false;
  4. ...
  5. }
is one way. There are other ways. For an example, see this. For a different style of form validation, see this link.
Feb 28 '07 #10

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

Similar topics

10
12981
by: reynoldscraigr | last post by:
Hi All, I am trying to call 2 functions from the 1 onMouseOver event on an anchor tag, but I can't seem to get it to work. the following should demonstrate <a onMouseOver="ShowMenu('Menu3');AddMenuToHoldArray('Menu3')">Menu 3</a>
7
5886
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll route. The problem being that I can't call these functions from the query designer in Access. I decided that I would try the route of declaring the functions from the dll file the same way you would for the Windows API. Access then complains that...
2
8718
by: Wei Wang | last post by:
Hi, Can I call multiple functions in one trigger? Something like this: CREATE TRIGGER match_cond_name_generate BEFORE INSERT OR UPDATE ON public.predicate_index FOR EACH ROW EXECUTE PROCEDURE public.match_cond_name_generate();
7
2459
by: pronerd | last post by:
Does any one know how to add a function to an event handler with out losing the current event handler? For example you can add multiple functions to a single event handler with something like : var someEle = document.getElementById( 'someId' ); if( someEle == null ) { return false; } someEle.onmouseover = new Function(" someFunction1(); someFunction2(); "); But if you do not know what if you do not know what...
2
1890
by: dnewton | last post by:
Hi, Can the onlclick event call multiple functions Using ASP.NET I have created an image button that runs my form at server side and makes use of an onClick event... but... I would also like to call a client side function when the person clicks this image button... I am not using an <input > tag for the image button, and would rather not change it to that.
3
3573
by: deepthisoft | last post by:
hai, I have 2 javascript funtions.I want to call these 2 functions using one button. my code is like this, <input type="button" value="ok" onclick="validate(this),change()">
3
1458
by: grezly | last post by:
I have a link in my webpage, that wants to call to functions at once. <td onclick="createform(event,<?php echo $startdag;?>,<?php echo $maand;?>,<?php echo $jaar;?>);createpic(event,<?php echo $startdag;?>,<?php echo $maand;?>,<?php echo $jaar;?>);" class="calendaroff" onmouseover="this.className='calendarover';" onmouseout="this.className='calendaroff';"> Normale this has to work. So there are 2 functions, createform and createpic....
1
2254
by: su817200 | last post by:
Dear Friend, I would like to run multiple functions on Button Click eg... <input type="button" value="Update" name="B1" onclick="ReadFileToString() timedRefresh(1500)"></p> It is giving error in the above line, what is the best way to achieve the above line using javascript... Rgds,
3
2662
by: cheenna | last post by:
<script language="javascript"> var numLinesAdded = 0; var numLinesRemove = 0; function generateRow(){ var d = document.getElementById("div"); var newDiv = document.createElement("newDiv"); newDiv.setAttribute("id", "newDiv_"+numLinesAdded); d.appendChild(newDiv);
0
8063
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8003
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8498
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8478
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6817
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1598
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.