In the select I already show the name of the data 'json', but I want to send to the db its id.
<section class="col col-6">
<label class="label"> Nombre </label>
<select name="room_id" id="room_id" class="form-control">
</select>
</section>
$.each(data.room_options, function(key, value) {
$('#room_id')
.append($("<option/>")
.attr("value",key.room_options)
.text(value.name));
$('#room_id').select2();
});