Select form Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Select


The form property returns the form that contains the drop-down list.

This property returns a form object on success.

Return Value

A reference to the form element containing the drop-down list. If the drop-down list is not in a form, null is returned

The following code shows how to return the id of the form containing the drop-down list:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<form id="myForm">
Select your favorite fruit:
<select id="mySelect">
</select>//from w  ww  . j  a v  a2s  .co  m

<button type="button" onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("mySelect");
    document.getElementById("demo").innerHTML = x;


Related Tutorials