View Single Post
Old 09-25-2012, 02:09 PM   PM User | #1
naveendk.55
New Coder

 
Join Date: Aug 2011
Posts: 88
Thanks: 5
Thanked 0 Times in 0 Posts
naveendk.55 is an unknown quantity at this point
Question dropdown value from javascript.

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>
naveendk.55 is offline   Reply With Quote