Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Search name Property

Input Search name Property

Input Search Object Reference Input Search Object

Example

Get the name of the search field:

var x = document.getElementById("mySearch").name;

x

The output is:

googlesearch

Try it »


Definition and Usage

The name property sets or returns the value of the name attribute of the search field.

The name attribute is typically used as the identifier for submitting form data to the server, or as a reference identifier for JavaScript on the client side.

Note: Data can only be submitted to the server after the form is submitted if the name attribute is set.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the name attribute.


Syntax

Return the name attribute:

searchObject

.name

Set the name attribute:

searchObject

.name=

name

Attribute 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

Change the name of the search field:

document.getElementById("mySearch").name = "newSearchName";

Try it »


Related pages

HTML Reference Manual: HTML name attribute


Input Search Object Reference Input Search Object