I want to make a HTML file with a select box.
So first of all, things are working perfectly fine:
<!DOCTYPE html>
<html>
<body>
<select id="options">
<option value="1">Option 1
<option value="2">Option 2
</select>
</body>
</html>
So, this code made a select box with 2 options:
Option 1
Option 2
Now I want to use JavaScript to check which option is selected. And I don't know how to do it.
<!DOCTYPE html>
<html>
<body>
<select id="options">
<option value="1">Option 1
<option value="2">Option 2
</select>
<script>
//What here?
</script>
</body>
</html>
So this is the structure of the code:
There are 2 options:
If the user select option 1, JavaScript will do Command 1.
If the user select option 2, JavaScript will do Command 2.