I have a javascript function. This function is supposed to populate a html select-box by adding options.
Argument passed is, for example, [['val1','txt1'],['val2','txt2']]
I expected that it would generate the html as under:
<select id='element_id'>
<option value='val1'>txt1</option>
<option value='val2'>txt2</option>
</select>
<script>
function popu_select(x) {
for (i in x) {
$('#element_id').append($(document.createElement("option")).attr("value", "i[0]").text("i[1]"));
}
</script>
But it is not populating the select-box. What I may be doing wrong here?
Regards, Vineet