

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the id of a form containing a dropdown list with JavaScript?
To get the id of a form with a drop-down list, use the id property in JavaScript.
Example
You can try to run the following code to find the id of a form containing drop-down list −
<!DOCTYPE html> <html> <body> <form id="myForm1"> <button id="btn" type="button" value="my_button">Demo</button> </form><br> <form id="myForm2"> <select id="mySelect"> <option>One</option> <option>Two</option> <option>Three</option> </select> </form> <script> var val = document.getElementById("mySelect").form.id; document.write("<br>Form id with dropdown: "+val); </script> </body> </html>
- Related Questions & Answers
- How to get the number of options in the dropdown list with JavaScript?
- How to remove options from a dropdown list with JavaScript?
- How to show all the options from a dropdown list with JavaScript?
- How to display the selected option in a dropdown list with JavaScript?
- How to show the index of the selected option in a dropdown list with JavaScript?
- How to select multiple options in a dropdown list with JavaScript?
- How to find the id of the form a button belongs to in JavaScript?
- How to get the value of the id attribute a link in JavaScript?
- JavaScript get the length of select options(dropdown)?
- How to return the id of the first image in a document with JavaScript?
- How to create a clickable dropdown menu with CSS and JavaScript?
- How to find the name of the first form in a document with JavaScript?
- How to get the data associated with the maximum id in a MySQL table?
- How to preselect a value in a dropdown list of items in HTML forms?
- How to get all options of a dropdown using Python Selenium webdriver?
Advertisements