<input type="button" id="demo" value = "Demo" /><br />
<select id="mySelect"></select>
<script type = "text/javascript" src = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
var fruits = new Array();
fruits[0] = { Text: "Mango", Value: "1" };
fruits[1] = { Text: "Banana", Value: "2" };
fruits[2] = { Text: "Orange", Value: "3" };
fruits[3] = { Text: "Grapes", Value: "4" };
$("#demo").live("click", function () {
//Clear the HTML Select DropdownList
$("#mySelect option").remove();
//Add Default Option
$("#mySelect").append(GetOption("Please select fruit", "0"));
//Loop through array and add options
$.each(fruits, function (index) {
$("#mySelect").append(GetOption(fruits[index].Text, fruits[index].Value));
});
});
function GetOption(text, value) {
return "<option value = '" + value + "'>" + text + "</option>"
}
</script>