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.
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:
<!DOCTYPE html> <html> <body> <form id="myForm"> Select your favorite fruit: <select id="mySelect"> <option>CSS</option> <option>Javascript</option> <option>Database</option> <option>SQL</option> </select>//from w ww . j a v a2s .co m </form> <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("mySelect").form.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>