Select nameProperty

Select 对象参考手册Select Object

Definition and Usage

The name property sets or returns the name of a drop-down list.

Syntax

Set the name property:

selectObject.name=name

Return the name property:

selectObject.name


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the name property


Example

Example

The following example will alert the name of the drop-down list:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function displayResult(){
  alert(document.getElementById("mySelect").name);
}
</script>
</head>
<body>

<form>
<select name="mySelect" id="mySelect">
  <option>Apple</option>
  <option>Pear</option>
  <option>Banana</option>
  <option>Orange</option>
</select>
</form>
<button type="button" onclick="displayResult()">Display the name of the drop-down list</button>

</body>
</html>

Try it Yourself »


Select 对象参考手册Select Object Other Extensions