FormDataEvent: FormDataEvent() constructor
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.
The FormDataEvent() constructor creates a new FormDataEvent object.
Syntax
js
new FormDataEvent(type, formEventInit)
Parameters
type-
A string with the name of the event. It is case-sensitive and browsers always set it to
formdata. options-
An object that, in addition of the properties defined in
Event(), can have the following properties:formData-
A
FormDataobject to pre-populate theFormDataEventwith. This would then be accessed through theFormDataEvent.formDataproperty.
Return value
A new FormDataEvent object.
Examples
js
const fd = new FormData();
fd.append("test", "test");
const fdEv = new FormDataEvent("formdata", { formData: fd });
for (const value of fdEv.formData.values()) {
console.log(value);
}
Specifications
| Specification |
|---|
| HTML> # the-formdataevent-interface> |
Browser compatibility
Loading...