Line 1: <div class="idx-default-form-field"><button type="submit" id="idx-do-register" class="idx-default-login-button">Register</button></div>
Line 2:<script>
$( "#idx-do-register" ).click(function() {
$( "#tomcat" ).click();
});</script>
Line 3:<button id="tomcat" onclick="myFunction()">Click me</button>
Line 4:<script>
function myFunction() {
window.location.href="https://idxseopremium.com/idxseo_templates/LoginForm/form.php";
}
</script>
In line 1 when the Register button is clicked, I need the line 4 myFunction to run. Line 3 when clicked will run the myFuction just fine…
Line 2 is where i tried to make it click Line 3 the button which would then run myFunction…
So I am looking for the simplest way either jquery or js to get my function to run any time some click the register button on line 1.
I won’t need line 2 or 3 if i can get the myFunction to run when the Register button is clicked…
Line 3 did not work anyway.
Question for you, am I right in assuming that the first button is inside a <form> element and you are trying to change where the form is submitted when you click the idx-do-register button? Or are you trying to just create a button that takes you to the form when they click the button?
If you are just trying to go to the form, you can change the button in line 1 from being of type `submit’ and dropping the type attribute. This will cause it to be a simple button.
Then of course we added the onclick handler to make it call your function. We put return false to make sure that it also cancels the any default submission of the form. This makes it so that only the code in your function should change the page.
Now of course that doesn’t submit any data in a form. If you are wanting to submit form data to form.php, you can write some code that will change the action attribute of the form and then call submit() on the form. See https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
Thanks Martyr2.that is fantastic… we are half way home… it activates the myFunction() just as I asked for but it seems to have failed to fire the first form that it normally would fire…
In other words when clicking Register i want that first form to in fact submit as it always did and at the same time or better yet maybe 1 second later it fires the second myFunction link… and inside that form.php that got loaded, at the bottom is an autosubmit when form.php is loaded it will auto submit as it has a code in the file to do that…
So again… when i click “Register” i want that form to do its normal stuff which is submit… and at the same time fire the second link…myfunction. It appears that now its firing myFunction but prevented from doing what it normally does…
And a perfect idea would be to submit the main form… then delay for 1 second for me to have time to use jquery to copy all the fields from the first form to the second one and then fire the second one which is firing myFunction.
Hope that makes sense… I do understand that when we have a button do something that it normally does we usually do not have it do the norm and the extra… I want the norm and 1 sec later the extra… but I think i can figure how how to delay the firing of the second one using a jquery or js delay… hopefully i can find that delay function and make it work… but if you know how to do that it would be great… That is fire the main form… then delay 1 second and fire the second myFunction. I cannot just send the main form twice (two places) as they are totally different forms they both just carry the same payload… same fields…
But thank you so much for what you have already done…
I am still stuck on this project… Martyr2 was very helpful in getting the 2nd form to fire but I still cannot get both to fire… So all I need is some ideas for killing 2 birds with one stone… If it causes conflict i suppose the main form could fire and then a js delay like 1 second and the second one would fire…It may be ok to fire them both at the same time… not sure if that would be a problem… my guess is one after the other would be best.
Line 2:<script>
$( "#idx-do-register" ).click(function() {
$( "#tomcat" ).click();
});</script>
Line 3:<button id="tomcat" onclick="myFunction()">Click me</button>
Line 4:<script>
function myFunction() {
window.location.href="https://idxseopremium.com/idxseo_templates/LoginForm/form.php";
}
</script>
As you can see in my script above i am trying to fire the main one first then the second one… and its ok if i need to put a 1 second delay in between them…
Thanks… I hope someone else will look and give me ideas, as its very important to me…