html - How do I programmatically set the value of a select box element using JavaScript? -
i have following html <select>
element:
<select id="leavecode" name="leavecode"> <option value="10">annual leave</option> <option value="11">medical leave</option> <option value="14">long service</option> <option value="17">leave without pay</option> </select>
using javascript function leavecode
number parameter, how select appropriate option in list?
function selectelement(valuetoselect) { var element = document.getelementbyid('leavecode'); element.value = valuetoselect; }
Comments
Post a Comment