


Error causes and solutions when form.submit() cannot submit the form_javascript skills
Go directly to the code:
<div id="register"> <h4>会员注册</h4> <div class="formdiv"> <form method="post" action="register.php?action=register" name="register" id="registerForm"> <dl> <dt>请认真填写以下内容</dt> <dd class="hasspan"> 用户名:<input type="text" name="username"> </dd> <dd class="hasspan"> 密码:<input type="password" name="pwd"> </dd> <dd class="hasspan"> 确认密码:<input type="password" name="pwdagain"> </dd> <dd id="tximg"> <img src="img/face/m01.gif" alt="选择头像" id="faceimg"> <input type="hidden" name="touxiang" value=""> <label id="imgsrclabel">m01.gif</label> </dd> <dd style="margin-right:120px;"> 验证码:<input type="text" name="code"> <span> <img src="code.php" alt="code" id="code" name="code"> <a href="#code" id="change">换一张</a> </span> </dd> <dd class="btns"> <input type="button" name="submit" id="submit" value="注册"> <input type="button" name="quit" id="quit" value="退出"> </dd> </dl> </form> </div> </div> 表单数据提交到本页面,下面是js处理 /*注册表单提交*/ function formDeal() { var btnSubmit = document.getElementById('submit'); var formId = document.getElementById('registerForm'); btnSubmit.onclick = function() { //表单的submit()方法不能提交表单 formId.submit(); } } 如果表单提交,在本页面有一段提示信息 if(!empty($_GET['action']) && $_GET['action'] == 'register') { echo '你提交了数据'; exit(); }
The result is that after testing for a long time, I did not see the prompt message. I thought that the code was wrong or the method was written wrong. I checked carefully and checked the official results document to confirm that there was no error.
formId.submit() cannot be submitted, so I have to change the type of btnSubmit to submit
this.type="submit"
After checking the information online, the reasons can be summed up in two points:
1. The form cannot have the tag name="submit"
2. "enctype="multipart/form-data"" cannot be missing from the form
After testing, these two points are ridiculous and do not solve my problem (maybe my problem environment is different)
Later, I thought some forum friends suggested that I change the ID of the registration button to a new name instead of submitting. After the correction, the form is submitted normally and the prompt message appears.
Final summary: Do not set the id of the button to submit, otherwise it may cause confusion and cause the submit() method of the form to fail to submit the form. When naming the ID, it is best not to duplicate the name with the existing API to avoid unnecessary annoyance.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



BinaryX's token name change: from BNX to FOUR, and then to FORM, the deep meaning behind strategic adjustments BinaryX recently changed the token symbol from $FOUR to $FORM, which has attracted widespread attention from the industry. This is not the first time BinaryX has changed its name, and its token symbol has undergone a transition from BNX to FOUR. This article will explore in-depth the strategic intentions behind this series of name change. 1. Token name change process and strategic considerations BinaryX initially launched the $BNX token based on the BNB chain in 2021 to support its Play-to-Earn (P2E) gaming ecosystem. In early 2024, in order to optimize the economic model, BinaryX divided $BNX and gradually expanded to GameF

Vue is a popular JavaScript framework that helps developers build interactive front-end applications. Forms are very common interface elements in Vue applications. When the user enters data into the form and submits it, we may need to listen for the form submission event. This article will introduce how to use the v-on:submit directive in Vue to listen for form submission events. First, defining form elements in Vue requires using Vue's data binding syntax. Let's say we have a form,

There can be multiple forms in html5. The rules allow multiple form tags to be used in the same HTML page. However, in order to prevent the backend from not recognizing it when submitting, you need to add different IDs or classes to the form. The syntax is "<from action="url" id=" id value 1">Form element</from><from action="url" id="id value 2">Form element</from>.....".

The tag defining a form in HTML5 is "<form>". The form tag is used to create an HTML form (form field) for user input to collect and transfer user information. All content in the form will be submitted to the server; the syntax "<form action="Submit Address" method="Submit Method " name="form name">form control</form>". A form can contain one or more form elements, such as input, select, and textarea.

This article gives you a detailed summary of the knowledge points related to form elements in HTML. I hope it will be helpful to you!

Solution to form form cannot be submitted to PHP: 1. Open the corresponding code file; 2. Modify the "onload="javascript:document.form1.submit();" statement; 3. Change the name of submit.

php记录搜索引擎蜘蛛爬行记录代码。php教程记录搜索引擎蜘蛛爬行记录代码 center form action=setup.php method=post table align=center tr td服务器:/tdtdinput value=localhost name=server //td /tr tr td用
