+ 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

17th Jun 2020, 1:03 PM
Josh Martin
Josh Martin - avatar
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
17th Jun 2020, 3:28 PM
Indira
Indira - avatar
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..
17th Jun 2020, 7:40 PM
Josh Martin
Josh Martin - avatar