There is a ComboBox when you select which transfers the received values from the database using ajax to the second ComboBox, when 1 value arrives, everything is displayed correctly, but if 2 values arrive, they are written in 1 line, and you need to add them to the next Options. I ask for your help
Code
var t = null; $( "#hotelid" ).change(function() { t = $( "#hotelid :selected" ); $.ajax({ type: 'GET', url: './modules/common.php', data: { fn: 'combobox', id: t.val() }, dataType: 'json', }).done(function(data, textStatus, jqXHR) { var list = data.list.rooms; var e =""; for (var i = 0; i < data.list.length; i++) { e += data.list[i].rooms; $( "#roomid option:selected").text(e); $( "#roomid option:selected").val(e); }; }); }); UP
Answer ajax
{list: [{rooms: "Еще комната"}, {rooms: "тест на кол-во"}]} Эти 2 значения должны попасть в `<option value="value"></option>` сейчас пока только 1 показывает. html
<select type="text" class="form-control" name="roomid" id="roomid"> <option value="value"></option> </select>