Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with "FormData()": type=submit inputs not included #14305

Closed
bluepuma77 opened this issue Mar 25, 2022 · 2 comments
Closed

Issue with "FormData()": type=submit inputs not included #14305

bluepuma77 opened this issue Mar 25, 2022 · 2 comments

Comments

@bluepuma77
Copy link

MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData

What information was incorrect, unhelpful, or incomplete?

The docs do not mention that FormData is ignoring input type=submit elements.
That is unexpected. A plain HTML submit of a form will include submit inputs.
This feature is useful to implement multiple different submit buttons.

Specific section or headline?

Potentially add it to "Note: Only successful form controls are included..."

What did you expect to see?

Information about this unexpected behaviour, potentially a "Gotchas" section.

Did you test this? If so, how?

<!DOCTYPE html>
<html>
  <body>
    <script>
      function handleSubmit(e) {
        e.preventDefault()
        const form = document.getElementById("myForm")
        const data = new FormData(form)
        for (var [key, value] of data.entries()) {
          console.log(key, value)
        }
        return false
      }
    </script>

    <form method="POST" id="myForm" onsubmit="return handleSubmit(event)">
      <input type="text" name="text" value="text" /><br />
      <input type="number" name="number" value="1" /><br />
      <input type="submit" name="submit1" value="Submit1" /><br />
      <input type="submit" name="submit2" value="Submit2" /><br />
    </form>

  </body>
</html>

Slightly different Svelte version in REPL

MDN Content page report details
@jenseng
Copy link
Contributor

jenseng commented Mar 10, 2023

This might be covered sufficiently by the new submitter parameter to FormData and this corresponding PR to document it.

@bluepuma77 would you mind taking a look to see if the new wording and examples are sufficient to resolve this?

@Josh-Cena
Copy link
Member

Closing assuming it's fixed

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants