英文:
On clicking the submit button of a form, it's not responding
问题
表单提交按钮未响应,尽管我已经在表单操作字段中指定了操作。
<div class="container">
<form action="php/record.php">
<h3>输入以下详细信息:</h3>
<form autocomplete="off" action="">
<div class="autocomplete" style="width:300px;">
<label for="school">学校:</label> <br>
<input id="school" type="text" name="School" placeholder="输入学校" required>
</div>
</form>
<br>
<form autocomplete="off" action="">
<div class="autocomplete" style="width:300px;">
<label for="school_ID">学校ID:</label> <br>
<input id="school_ID" type="text" name="School_ID" placeholder="输入学校ID" required>
</div>
</form>
<br>
<label for="class">班级:</label>
<select name="Class" id="class">
<option value="I">I</option>
<option value="II">II</option>
<option value="III">III</option>
<option value="IV">IV</option>
<option value="V">V</option>
</select>
<label for="sec">Sec:</label>
<select name="sec" id="sec">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br><br>
<label for="Film_1">电影1:</label> <br>
<input id="Film_1" type="text" placeholder="输入电影1" name="Film_1" required>
<br><br>
<label for="Film_2">电影2(如果适用):</label><br>
<input id="Film_2" type="text" placeholder="输入电影2" name="Film_2">
<br><br>
<label for="Film_3">电影3(如果适用):</label><br>
<input id="Film_3" type="text" placeholder="输入电影3" name="Film_3">
<br><br>
<button id="submit_btn" type="submit">提交</button>
<input name="Picture" type="file" onchange="readURL(this)" accept="image/*">
</form>
</div>
请告诉我在我的代码中哪里出错,点击提交按钮时没有任何反应。我希望在点击提交按钮时重定向到另一个页面,即record.php。
英文:
Form submit button is not responding even though I have specified the action, in the form action field.
<div class="container">
<form action="php/record.php">
<h3>Enter the following details :</h3>
<form autocomplete="off" action="">
<div class="autocomplete" style="width:300px;">
<label for="school">School :</label> <br>
<input id="school" type="text" name="School" placeholder="Enter School" required>
</div>
</form>
<br>
<form autocomplete="off" action="">
<div class="autocomplete" style="width:300px;">
<label for="school_ID">School ID :</label> <br>
<input id="school_ID" type="text" name="School_ID" placeholder="Enter School ID" required>
</div>
</form>
<br>
<label for="class">Class :</label>
<select name="Class" id="class">
<option value="I">I</option>
<option value="II">II</option>
<option value="III">III</option>
<option value="IV">IV</option>
<option value="V">V</option>
</select>
<label for="sec">Sec : </label>
<select name="sec" id="sec">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br><br>
<label for="Film_1">Film 1 :</label> <br>
<input id = "Film_1" type= "text" placeholder="Enter film 1" name="Film_1" required>
<br>
<br>
<label for="Film_2">Film 2 (if applicable) :</label><br>
<input id = "Film_2" type="text" placeholder="Enter film 2" name="Film_2">
<br>
<br>
<label for="Film_3">Film 3 (if applicable) :</label><br>
<input id = "Film_3" type="text" placeholder="Enter film 3" name="Film_3">
<br>
<br>
<button id="submit_btn" type="submit">Submit</button>
<input name="Picture" type="file" onchange="readURL(this)" accept="image/*">
</form>
</div>
</body>
Please suggest me where I'm going wrong in my code as nothing is happening on clicking the submit button. I want to redirect to another page i.e. record.php on clicking submit
答案1
得分: 1
这不是一个提交按钮。
一个提交按钮应该有 type="submit"
(或者根本没有 type
属性,因为submit
是默认值)。
type="button"
用于没有默认行为的按钮(即当您希望使用 JavaScript 添加行为时使用)。
表单不应嵌套。请编写有效的 HTML。移除额外的表单。
英文:
> <button id="submit_btn" type="button">Submit</button>
That isn't a submit button.
A submit button has type="submit"
(or no type
attribute at all as submit
is the default value).
type="button"
is used for buttons which has no default behaviour (i.e. when you want to add behaviour using JavaScript).
> <form action="php/record.php">
> <h3>Enter the following details :</h3>
>
> <form autocomplete="off" action="">
Forms may not be nested. Write valid HTML. Remove the extra form.
答案2
得分: 1
您没有指定提交按钮。
将
<button id="submit_btn" type="button">Submit</button>
更改为
<button id="submit_btn" type="submit">Submit</button>
此外,您有多个嵌套的表单,这是不允许的,也可能导致浏览器行为不符合预期。
英文:
You did not specify a submit button.
Change
<button id="submit_btn" type="button">Submit</button>
To
<button id="submit_btn" type="submit">Submit</button>
Also you have several forms nested, which isn't allowed and can also cause your browser to behave unexpected
答案3
得分: 0
你的代码中有一些错误。
你可以使用以下代码:
<div class="container">
<form action="php/record.php">
<h3>输入以下详细信息:</h3>
<div class="autocomplete" style="width:300px;">
<label for="school">学校:</label> <br>
<input id="school" type="text" name="School" placeholder="输入学校" required>
</div>
<br>
<div class="autocomplete" style="width:300px;">
<label for="school_ID">学校ID:</label> <br>
<input id="school_ID" type="text" name="School_ID" placeholder="输入学校ID" required>
</div>
<br>
<label for="class">班级:</label>
<select name="Class" id="class">
<option value="I">I</option>
<option value="II">II</option>
<option value="III">III</option>
<option value="IV">IV</option>
<option value="V">V</option>
</select>
<label for="sec">班次:</label>
<select name="sec" id="sec">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br><br>
<label for="Film_1">影片1:</label> <br>
<input id="Film_1" type="text" placeholder="输入影片1" name="Film_1" required>
<br>
<br>
<label for="Film_2">影片2(如果适用):</label><br>
<input id="Film_2" type="text" placeholder="输入影片2" name="Film_2">
<br>
<br>
<label for="Film_3">影片3(如果适用):</label><br>
<input id="Film_3" type="text" placeholder="输入影片3" name="Film_3">
<br>
<br>
<input name="Picture" type="file" onchange="readURL(this)" accept="image/*">
<button id="submit_btn" type="submit">提交</button>
</form>
</div>
英文:
You have some mistakes in the code.
you can use that code.
<div class="container">
<form action="php/record.php">
<h3>Enter the following details :</h3>
<div class="autocomplete" style="width:300px;">
<label for="school">School :</label> <br>
<input id="school" type="text" name="School" placeholder="Enter School" required>
</div>
<br>
<div class="autocomplete" style="width:300px;">
<label for="school_ID">School ID :</label> <br>
<input id="school_ID" type="text" name="School_ID" placeholder="Enter School ID" required>
</div>
<br>
<label for="class">Class :</label>
<select name="Class" id="class">
<option value="I">I</option>
<option value="II">II</option>
<option value="III">III</option>
<option value="IV">IV</option>
<option value="V">V</option>
</select>
<label for="sec">Sec : </label>
<select name="sec" id="sec">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br><br>
<label for="Film_1">Film 1 :</label> <br>
<input id = "Film_1" type= "text" placeholder="Enter film 1" name="Film_1" required>
<br>
<br>
<label for="Film_2">Film 2 (if applicable) :</label><br>
<input id = "Film_2" type="text" placeholder="Enter film 2" name="Film_2">
<br>
<br>
<label for="Film_3">Film 3 (if applicable) :</label><br>
<input id = "Film_3" type="text" placeholder="Enter film 3" name="Film_3">
<br>
<br>
<input name="Picture" type="file" onchange="readURL(this)" accept="image/*">
<button id="submit_btn" type="submit">Submit</button>
</form>
</div>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论