DOM Interfaces

FormData

Build a form with the HTML form generator

Stores an ordered list of named values for form submission. Values may be strings or files, and duplicate names are allowed. Constructing it from a form includes successful named controls, not every input; disabled fields and unchecked checkboxes are excluded. Creating the object does not send a request. Example result: [["city","Baku"]].

Formal Syntax & Structure

html syntaxhtml
new FormData(form, submitter)

Return Value

FormData

Mutable ordered entry list.

Working Example

Example Snippethtml
<form>  <label>    City    <input name="city" value="Baku">  </label>  <input name="ignored" value="x" disabled></form><p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  const data = new FormData(document.querySelector("form"));  result.textContent = JSON.stringify([...data]);  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference