I have a value receiving from database and saved it to a Javascript variable. I would like to pass this as an option to dropdown. How to achieve this.
I tried below code that didn't work. ( I want the name "Country" in dropdown option).
Code:
window.onload = hello;
function hello()
{
var dd = document.getElementById("dropdownID");
dd.options[dd.selectedIndex].value = "Country";
}
below is dropdown.
<select id="dropdownID" onchange="hello()">
<option value="one"> </option>
</select>