S
S
semki0962016-05-23 16:30:03
JavaScript
semki096, 2016-05-23 16:30:03

How to attach a JSON data object to a select dropdown list?

There is such a JSON How can I place this object in the drop-down list, that is, do this{"row":["5","31","6","4"]}

<select name="row">
<option value="5">1</option>
<option value="31">2</option>
<option value="6" selected="selected">3</option>
<option value="4">4</option>
</select>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kpa6uu, 2016-05-23
@semki096

на работоспособность не проверял, но должно быть близко

var yo = JSON.parse(data);
for(var i = 0; i < data['row'].length; i++){
$("#super_select").append($('<option>', {
    value: data['row'][i],
    text: i
}));
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question