Home > Web Front-end > HTML Tutorial > How to solve the problem when the form automatically submits and jumps to other pages after pressing Enter in the web page?

How to solve the problem when the form automatically submits and jumps to other pages after pressing Enter in the web page?

php中世界最好的语言
Release: 2018-02-02 10:19:15
Original
3552 people have browsed it

This time I will show you how to solve the problem of automatically submitting the form and jumping to other pages after pressing Enter in the web page. Precautions Yes Which ones, the following are practical cases, let’s take a look.

The form is automatically submitted after pressing Enter on the web page, and runs to other pages.
There is a form of Query. I originally wanted to query it when I clicked the query, but the test result is that it runs when pressing Enter. Went to other pages.

<form action="notice.php" method="get"> 
... 
<button type=&#39;button&#39; onclick ="search_wj()" class="btn btn-ok">查询</button> 
</form>
Copy after login

Solution:
Add an onsubmit="search_wj();return false;" to the form

<form action="notice.php" onsubmit="search_wj();return false;" method="get"> 
... 
<button type=&#39;button&#39; onclick ="search_wj()" class="btn btn-ok">查询</button> 
</form>
Copy after login

I believe I saw it You have mastered the methods in these cases. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Related reading:

How to implement a simple calculator in HTML

Example of how to add attributes using style

The above is the detailed content of How to solve the problem when the form automatically submits and jumps to other pages after pressing Enter in the web page?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template