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

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -