Answers for "select input option with js"

6

how take values form select tag in js

<body>
   
   <select id="list" style="padding: 10px;" onchange="getSelectValue();">
     <option value="js">JavaScript</option>
     <option value="php">PHP</option>
     <option value="c#">Csharp</option>
     <option value="java">Java</option>
     <option value="node">Node.js</option>
   </select>
   
    <script>
        function getSelectValue()
        {
            var selectedValue = document.getElementById("list").value;
            alert(selectedValue);
        }
        getSelectValue();
    </script>
 </body>
Posted by: Guest on June-12-2020
0

how to select input element javascript

<input type="text" id="text-box" size="20" value="Hello world!">
<button onclick="selectText()">Select text</button>

<script>
  /* Use The
  .focus();
  .select(); 
  Methods */
function selectText() {
  const input = document.getElementById('text-box');
  input.focus();
  input.select();
}
</script>
Posted by: Guest on May-02-2021

Code answers related to "select input option with js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language