Input Search nameProperty
Examples
Get the name of the search field:
var x = document.getElementById("mySearch").name;
xThe output result is:googlesearch
Try it Yourself »
Definition and Usage
The name property sets or returns the value of the name attribute of the search field.
The name attribute is usually used as an identifier for submitting form data to the server, or as a reference identifier in JavaScript on the client side.
Note:Only when the name attribute is set can data be submitted to the server after form submission.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the name attribute.
Syntax
Return the name attribute:
searchObject.name
Set the name attribute:
searchObject.name=name
Property Values
| Value | Description |
|---|---|
| name | Describes the name of the search field |
Technical Details
| Return value: | A string representing the name of the search field |
|---|
More Examples
Example
Modify the name of the search field:
document.getElementById("mySearch").name = "newSearchName";
Try it Yourself »
Related Pages
HTML Reference Manual:HTML <input> name Attribute
Input Search Object Other Extensions