Use HTML dropdown list values with JavaScript -
this i'm trying do:
the user selects either option "one" or option "two". if user select "one" result 66 + 45 or if user select "two" result 35 + 45.
how can implement using html , javascript?
this i've done far:
html:
<select id="number"> <option>one</option> <option>two</option> </select> ... // result <div id="result"></div> javascript:
function test(eventinfo) { var userselection = document.getelementbyid("number").value; if () { result = 66 + 45; } else { result = 35 + 45; } var greetingstring = userselection; document.getelementbyid("result").innertext = greetingstring; }
consider:
<select id="number"> <option value="66">one</option> <option value="35">two</option> </select> then:
result = 45 + +document.getelementbyid("number").value;
Comments
Post a Comment