ElementInternals.setFormValue()
The setFormValue() method of the ElementInternals interface sets the element's submission value and state, communicating these to the user agent.
Syntax
ElementInternals.setFormValue(value); ElementInternals.setFormValue(value, state);
Parameters
value-  
A
File, or astring, orFormDataas the value to be submitted to the server. - 
stateOptional -  
A
File, or astring, orFormDatarepresenting the input made by the user. This allows the application to re-display the information that the user submitted, in the form that they submitted it, if required. 
Note: In general, state is used to pass information specified by a user, the value is suitable for submission to a server, post sanitization. For example, if a custom element asked a user to submit a date, the user might enter "3/15/2019". This would be the state. The server expects a date format of 2019-03-15, the date in this format would be passed as the value.
Return value
Undefined.
Exceptions
- 
NotSupportedErrorDOMException -  
Thrown if the element does not have its
formAssociatedproperty set totrue. 
Examples
In the following example, a checkbox custom element sets on as the value to send to the server, and checked as the state.
this.internals_.setFormValue("on","checked");
Specifications
| Specification | 
|---|
| HTML Standard (HTML) # dom-elementinternals-setformvalue  | 
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
setFormValue | 
77  | 
79  | 
No  | 
No  | 
64  | 
No  | 
77  | 
77  | 
No  | 
55  | 
No  | 
12.0  | 
    © 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
    https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue