Answers for "selected in dropdown list html"

0

html dropdown selected

'Audi' will be the first item seleted by default:

<label for="cars">Choose a car:</label>

<select id="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="vw">VW</option>
  <option value="audi" selected>Audi</option>
</select>
Posted by: Guest on July-02-2021
0

Show html when a list in the dropdown is selected

<!DOCTYPE html>
<html>
   <body>
      <form id="myForm">
         <select id="selectNow">
            <option>One</option>
            <option>Two</option>
            <option>Three</option>
         </select>
         <input type="button" onclick="display()" value="Click">
      </form>
      <p>Select and click the button</p>
      <script>
         function display() {
            var obj = document.getElementById("selectNow");
            document.write(obj.options[obj.selectedIndex].text);
         }
      </script>
   </body>
</html>
Posted by: Guest on June-22-2020

Code answers related to "selected in dropdown list html"

Browse Popular Code Answers by Language