I want to create a form with HTML, that when submitting it will run a javascript function (the function itself needs to contact a local server (localhost:...)), but when inside the javascript function I use window.open(...) a new tab is opened. I want the form to be submitted but not to change the current page, meaning to stay on the form. How do I do that?
Asked
Active
Viewed 9,732 times
1
-
Possible duplicate of [Submit form and stay on same page?](http://stackoverflow.com/questions/5733808/submit-form-and-stay-on-same-page) – Ciro Santilli OurBigBook.com May 30 '16 at 16:40
2 Answers
2
If you are using type="submit"
but want to stay on the same page you could try changing the input type to button so that it would read...
input type="button" value="Submit" onclick="myFunction()"
and in the function call the box variables with...
var name = document.formName.boxName.value;

Jason Yost
- 4,807
- 7
- 42
- 65

hello and lullaby
- 21
- 2
0
Set the target
for your form:
<form target="_blank" action="http://example.com">.....