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
13 107446
I think the easiest way would be make 2 functions then a 3 that will decide which of the 2 it wants to call.
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 -
Dim prevPageURL As String = Page.PreviousPage.ToString
-
cmdModifyForm.Attributes.Add("PostBackUrl", prevPageURL)
-
and then doing the session variables in cmdModifyForm_Click. We'll see how that goes.
Thanks again
- LB
You can just call a single function with the onclick, then this will call 2 other function. -
<button onclick="javascript: funcCaller();" value="press me" />
-
-
<script type="text/javascript">
-
-
function funcCaller() {
-
funcOne();
-
funcTwo();
-
}
-
-
...
-
-
</script>
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
<input type="button" onclick="function1(); function2(); function3(); function4(); function5();">
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.match(NumExpression)){
alert("Invalid, Number Only");
frm.scode.select();
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
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.match(NumExpression)){
alert("Invalid, Number Only");
frm.scode.select();
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.
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...
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: - function formCheck {
-
if (!numCheck()) return false;
-
if (!emailCheck()) return false;
-
...
-
}
is one way. There are other ways. For an example, see this. For a different style of form validation, see this link.
i want to call
onClick="document.pressed=this.value"
and
onClick="return validate();
what do i write ?
gits 5,390
Expert Mod 4TB
just wrap both calls in one function and call that function on click ... or write both of the statements separated with a semicolon in one place ...
if there are many validations,then will you be using multiple functions??
- function Validation3() {
-
if(Validation1() !=false)
-
{
-
Validation2();
-
}
-
}
-
-
<input type="submit" onclick="return Validation3()"/>
In the first function you have return a Boolean value. Suppose you want call second function only if the first function returns true. you can use the above code. so with out the success of first function you can't call second function
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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 : ...
|
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...
|
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()">
|
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...
|
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...
|
by: cheenna |
last post by:
<script language="javascript">
var numLinesAdded = 0;
var numLinesRemove = 0;
function generateRow(){
var d = document.getElementById("div");
var newDiv =...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
| |