php 单击表单的提交按钮时,表单没有响应

lxkprmvk  于 2023-03-07  发布在  PHP
关注(0)|答案(3)|浏览(248)

表单提交按钮没有响应,即使我已经在表单操作字段中指定了操作。

<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>

请告诉我我的代码哪里出错了,因为点击提交按钮时什么都没有发生。我想重定向到另一个页面,即点击提交record.php

w8f9ii69

w8f9ii691#

<button id="submit_btn" type="button">Submit</button>

这不是提交按钮。
提交按钮具有type="submit"(或者根本没有type属性,因为submit是默认值)。
type="button"用于没有默认行为的按钮(即当您希望使用JavaScript添加行为时)。

<form action="php/record.php">
    <h3>Enter the following details :</h3>

    <form autocomplete="off" action="">

窗体不能嵌套。请编写有效的HTML。删除多余的窗体。

oug3syen

oug3syen2#

您没有指定提交按钮。
变更

<button id="submit_btn" type="button">Submit</button>

<button id="submit_btn" type="submit">Submit</button>

此外,您还嵌套了多个窗体,这是不允许的,而且还会导致浏览器出现意外行为

nbysray5

nbysray53#

你的代码有些错误,你可以用那个代码。

<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>

相关问题