点击表单的提交按钮后,它没有响应。

huangapple go评论71阅读模式
英文:

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.

&lt;div class=&quot;container&quot;&gt;
&lt;form action=&quot;php/record.php&quot;&gt;
&lt;h3&gt;Enter the following details :&lt;/h3&gt;
&lt;form autocomplete=&quot;off&quot; action=&quot;&quot;&gt;
&lt;div class=&quot;autocomplete&quot; style=&quot;width:300px;&quot;&gt;
&lt;label for=&quot;school&quot;&gt;School :&lt;/label&gt; &lt;br&gt;
&lt;input id=&quot;school&quot; type=&quot;text&quot; name=&quot;School&quot; placeholder=&quot;Enter School&quot; required&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;br&gt;
&lt;form autocomplete=&quot;off&quot; action=&quot;&quot;&gt;
&lt;div class=&quot;autocomplete&quot; style=&quot;width:300px;&quot;&gt;
&lt;label for=&quot;school_ID&quot;&gt;School ID :&lt;/label&gt; &lt;br&gt;
&lt;input id=&quot;school_ID&quot; type=&quot;text&quot; name=&quot;School_ID&quot; placeholder=&quot;Enter School ID&quot; required&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;br&gt;
&lt;label for=&quot;class&quot;&gt;Class :&lt;/label&gt;
&lt;select name=&quot;Class&quot; id=&quot;class&quot;&gt;
&lt;option value=&quot;I&quot;&gt;I&lt;/option&gt;
&lt;option value=&quot;II&quot;&gt;II&lt;/option&gt;
&lt;option value=&quot;III&quot;&gt;III&lt;/option&gt;
&lt;option value=&quot;IV&quot;&gt;IV&lt;/option&gt;
&lt;option value=&quot;V&quot;&gt;V&lt;/option&gt;
&lt;/select&gt;
&lt;label for=&quot;sec&quot;&gt;Sec : &lt;/label&gt;
&lt;select name=&quot;sec&quot; id=&quot;sec&quot;&gt;
&lt;option value=&quot;A&quot;&gt;A&lt;/option&gt;
&lt;option value=&quot;B&quot;&gt;B&lt;/option&gt;
&lt;option value=&quot;C&quot;&gt;C&lt;/option&gt;
&lt;option value=&quot;D&quot;&gt;D&lt;/option&gt;
&lt;/select&gt;
&lt;br&gt;&lt;br&gt;
&lt;label for=&quot;Film_1&quot;&gt;Film 1 :&lt;/label&gt; &lt;br&gt;
&lt;input id = &quot;Film_1&quot; type= &quot;text&quot; placeholder=&quot;Enter film 1&quot; name=&quot;Film_1&quot; required&gt;   
&lt;br&gt;
&lt;br&gt;
&lt;label for=&quot;Film_2&quot;&gt;Film 2 (if applicable) :&lt;/label&gt;&lt;br&gt;
&lt;input id = &quot;Film_2&quot; type=&quot;text&quot; placeholder=&quot;Enter film 2&quot; name=&quot;Film_2&quot;&gt;
&lt;br&gt;
&lt;br&gt;
&lt;label for=&quot;Film_3&quot;&gt;Film 3 (if applicable) :&lt;/label&gt;&lt;br&gt;
&lt;input id = &quot;Film_3&quot; type=&quot;text&quot; placeholder=&quot;Enter film 3&quot; name=&quot;Film_3&quot;&gt;
&lt;br&gt;
&lt;br&gt;
&lt;button id=&quot;submit_btn&quot; type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
&lt;input name=&quot;Picture&quot; type=&quot;file&quot; onchange=&quot;readURL(this)&quot; accept=&quot;image/*&quot;&gt;
&lt;/form&gt;
&lt;/div&gt;    
&lt;/body&gt;

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=&quot;submit&quot; (or no type attribute at all as submit is the default value).

type=&quot;button&quot; 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

&lt;button id=&quot;submit_btn&quot; type=&quot;button&quot;&gt;Submit&lt;/button&gt;

To

&lt;button id=&quot;submit_btn&quot; type=&quot;submit&quot;&gt;Submit&lt;/button&gt;

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.

&lt;div class=&quot;container&quot;&gt;
&lt;form action=&quot;php/record.php&quot;&gt;
&lt;h3&gt;Enter the following details :&lt;/h3&gt;
&lt;div class=&quot;autocomplete&quot; style=&quot;width:300px;&quot;&gt;
&lt;label for=&quot;school&quot;&gt;School :&lt;/label&gt; &lt;br&gt;
&lt;input id=&quot;school&quot; type=&quot;text&quot; name=&quot;School&quot; placeholder=&quot;Enter School&quot; required&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;autocomplete&quot; style=&quot;width:300px;&quot;&gt;
&lt;label for=&quot;school_ID&quot;&gt;School ID :&lt;/label&gt; &lt;br&gt;
&lt;input id=&quot;school_ID&quot; type=&quot;text&quot; name=&quot;School_ID&quot; placeholder=&quot;Enter School ID&quot; required&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;label for=&quot;class&quot;&gt;Class :&lt;/label&gt;
&lt;select name=&quot;Class&quot; id=&quot;class&quot;&gt;
&lt;option value=&quot;I&quot;&gt;I&lt;/option&gt;
&lt;option value=&quot;II&quot;&gt;II&lt;/option&gt;
&lt;option value=&quot;III&quot;&gt;III&lt;/option&gt;
&lt;option value=&quot;IV&quot;&gt;IV&lt;/option&gt;
&lt;option value=&quot;V&quot;&gt;V&lt;/option&gt;
&lt;/select&gt;
&lt;label for=&quot;sec&quot;&gt;Sec : &lt;/label&gt;
&lt;select name=&quot;sec&quot; id=&quot;sec&quot;&gt;
&lt;option value=&quot;A&quot;&gt;A&lt;/option&gt;
&lt;option value=&quot;B&quot;&gt;B&lt;/option&gt;
&lt;option value=&quot;C&quot;&gt;C&lt;/option&gt;
&lt;option value=&quot;D&quot;&gt;D&lt;/option&gt;
&lt;/select&gt;
&lt;br&gt;&lt;br&gt;
&lt;label for=&quot;Film_1&quot;&gt;Film 1 :&lt;/label&gt; &lt;br&gt;
&lt;input id = &quot;Film_1&quot; type= &quot;text&quot; placeholder=&quot;Enter film 1&quot; name=&quot;Film_1&quot; required&gt;   
&lt;br&gt;
&lt;br&gt;
&lt;label for=&quot;Film_2&quot;&gt;Film 2 (if applicable) :&lt;/label&gt;&lt;br&gt;
&lt;input id = &quot;Film_2&quot; type=&quot;text&quot; placeholder=&quot;Enter film 2&quot; name=&quot;Film_2&quot;&gt;
&lt;br&gt;
&lt;br&gt;
&lt;label for=&quot;Film_3&quot;&gt;Film 3 (if applicable) :&lt;/label&gt;&lt;br&gt;
&lt;input id = &quot;Film_3&quot; type=&quot;text&quot; placeholder=&quot;Enter film 3&quot; name=&quot;Film_3&quot;&gt;
&lt;br&gt;
&lt;br&gt;
&lt;input name=&quot;Picture&quot; type=&quot;file&quot; onchange=&quot;readURL(this)&quot; accept=&quot;image/*&quot;&gt;
&lt;button id=&quot;submit_btn&quot; type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
&lt;/form&gt;
&lt;/div&gt;    

huangapple
  • 本文由 发表于 2023年3月3日 18:17:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75625773.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定