shaair
shaair

Reputation: 985

form submit by name not working

i want to submit nested form but i am facing two different behaviors like like if submit by index then working fine but if submit by name the parent form submiting.

    <form name="form1" action="/action_page.php">
      First name:<br>
      <input type="text" name="firstname" value="Mickey">
      <br>
      Last name:<br>
      <input type="text" name="lastname" value="Mouse">
      <br><br>
      <input type="submit" value="Submit">
          <form name="form2" action="/action_page.php">
          First name:<br>
          <input type="text" name="firstname" value="Mickey">
          <br>
          Last name:<br>
          <input type="text" name="lastname" value="Mouse">
          <br><br>
          <input type="submit" value="Submit">
        </form> 
    </form>

This is working

$('form')[1].submit();

Not working

$("form[name='form2']").submit(); // submit form1 instead

Upvotes: 0

Views: 394

Answers (1)

Mario
Mario

Reputation: 968

just researched myself, it seems you can't nest forms. Can you nest html forms?

My solution would be to make two different forms or create them dynamically and append to the previous one.

Upvotes: 1

Related Questions