skip to Main Content

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

3

Answers


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

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. 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>    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search