We would like to know how to fill array data to form select control.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!-- w ww . ja v a2 s. c o m-->
var selectList = {};
selectList[1] = "james";
selectList[2] = "mark";
$.each(selectList, function (key, value) {
$('#LKAanvrager').append($("<option/>", {
value: key,
text: value
}));
});
});
</script>
</head>
<body>
<select id="LKAanvrager" />
</body>
</html>
The code above is rendered as follows: