Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please how can I call these JavaScript Function for an Onclick Even.

Below is the submit button script;
<button data-uifm-tabnum="0" class="rockfm-txtbox-inp-val btn" type="submit" data-val-btn="Submit" data-val-subm="Sending" onclick="javascript:rocketfm.submitForm(this);return false;" >Submit</button>


Below is a Single Onclick Function that submit form -1st Function;
onclick="javascript:rocketfm.submitForm(this);return false;"


Below is the redirect Function I would like to add as the second function -2nd Function:
top.location = 'https://google.com';


What I have tried:

I need help with code sample on how to execute 1stFunction, followed my the 2nd function. 

Thank you.
Posted
Updated 14-Jul-19 17:25pm
Comments
Richard Deeming 16-Jul-19 14:34pm    
Depending on what that submitForm function does, I suspect one of two things will happen: either
a) submitting the form will prevent the top-level navigation; or
b) the top-level navigation will prevent the form from being submitted.

Worse, this will be almost impossible to debug, since it will depend on your network speed, and the speed of the handler which receives the form submission.

I'd be very wary of doing something like this.

You can call any number of functions in sequence till the time you don't return false from any function in chain.
JavaScript
<button data-uifm-tabnum="0" class="rockfm-txtbox-inp-val btn" type="button" data-val-btn="Submit" data-val-subm="Sending" onclick="javascript:rocketfm.submitForm(this);redirect();">Submit</button>

However, you should look at the scenario where you really need this. Its suggested to call a single handler for a button and call other functions from there.
 
Share this answer
 
Quote:
Please how can I call these JavaScript Function for an Onclick Event.

Short answer, you don't, not directly.
An event calls only 1 function, but nobody said that it have to be the real functions you want, the trick is to call an intermediate function which call all the functions you need.
Try something like:
JavaScript
onclick="javascript:MyIntermediate ()"
...
function MyIntermediate () {
    rocketfm.submitForm(this);
    top.location = 'https://google.com';
    return false;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900