+ 1
Can someone please give me some hints working with <select> and <option> using JavaScript?
Am a beginner..ws trying to get images to change based on hours selected by the user. I managed to make it change based on hours. But not on the hour selected by user. https://code.sololearn.com/WR7RdVSO9rUf/?ref=app
2 Answers
+ 3
Josh Martin
>The HTML <select> elementÂ
represents a control that provides a menu of options:
<label for="cars">Choose a car:</label>
<select name="cars" id="cars" required>
  <option value="">None</option>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
</select>
>The HTML <option> element is used to define an item contained in a <select>, an <optgroup>, or a <datalist> element
0
Thanks...i might ave gotten the answer.
<label> input test </label>
<select name="test" id="test">
<option value="0">test1</option>
<option value="1"> test2</option>
</select>
<br><br>
<button id="test" onclick="test()">test</button>
<script>
function test(){
var b = document.getElementById("test").value;
if(b=0){
alert("hello");
}
}
But i came across this issues...so when b = 0 ...it doesn't work, but when b = 1 it works..