json html select
var massiv = [ { "key": 0, "duration": 4, "price": 1000000 },{ "key": 1, "duration": 6, "price": 1250000 },{ "key": 2, "duration": 12, "price": 1500000 }, ];
function numberWithSpaces(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
var elementString = "<select>";
for (var i in massiv) {
elementString += '<option value="'+massiv[i].key+'">'+massiv[i].duration+'</option>';
}
//+numberWithSpaces(massiv[i].price)+
elementString += "</select>";
$("#seect").append(elementString);
$('select').on('change', function() {
$("#qiymat").text(numberWithSpaces(massiv[this.value].price));
});