Web APIs
FormData()
Creates an entry list, optionally populated from a form and a selected submitter. Does not send a network request.
Formal Syntax & Structure
javascript syntaxjavascript
new FormData(form?, submitter?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| form | HTMLFormElement | Optional form to read. |
| submitter | HTMLElement | Optional associated submit button. |
Return Value
FormData
New entry list.
Working Example
Example Snippetjavascript
const f=document.createElement("form");for(const [name,value,disabled] of [["item","pen",false],["hiddenField","x",true],["","ignored",false]]){const i=document.createElement("input");i.name=name;i.value=value;i.disabled=disabled;f.append(i);}console.log(JSON.stringify([...new FormData(f)]));