Append option to select via Javascript
Description
The following code shows how to append option to select via Javascript.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.6.4.js'></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css">
<script type='text/javascript'
src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!-- w w w. j a v a 2 s. c o m-->
var contributionAmount = '5.00, 10.00, 15.00, 25.00, 50.00, 100.00';
var temp = new Array();
temp = contributionAmount.split(',');
for(var i=0; i<temp.length; i++){
$('#amountsList').append('<option value="'+temp[i]+'">' +temp[i]+ '</option>');
}
});//]]>
</script>
</head>
<body>
<select data-native-menu="true" id="amountsList">
</select>
</body>
</html>