javascript - Html submit a form, but stay on the same page - Stack Overflow

I want to create a form with HTML, that when submitting it will run a javascript function (the function

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?

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?

Share Improve this question asked Nov 6, 2014 at 12:13 user3636583user3636583 1772 gold badges3 silver badges12 bronze badges 1
  • Possible duplicate of Submit form and stay on same page? – Ciro Santilli OurBigBook. Commented May 30, 2016 at 16:40
Add a ment  | 

2 Answers 2

Reset to default 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;

Set the target for your form:

<form target="_blank" action="http://example.">.....

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745571162a4633689.html

相关推荐

  • javascript - Html submit a form, but stay on the same page - Stack Overflow

    I want to create a form with HTML, that when submitting it will run a javascript function (the function

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信