i have data in select option
$.ajax({
url: "<?php echo site_url('method/....'); ?>",
method: "POST",
data: {
id: id
},
async: false,
dataType: 'json',
success: function(data) {
var $html = $('.appendBarangs[indexOf=' + n + ']').html('<option value="">pilih</option>')
for (y in data)
$html.append('<option value = ' + data[y].id_barang + ' name=' + data[y].barang + '>' + data[y].barang + '</option>');
$('select').on('change', function() { //here i make a function take attribute name
var dapet = this.options[this.selectedIndex].label;
console.log('dapet', dapet)
$('.attributItem[indexOf=' + n + ']').val(dapet);
});
},
})
here I take the name attribute from the results of the ajax response, then I throw it into the input form based on index
this my form input , but not work
'<input class="form-control attributItem" name="item[]" type="text" indexOf='+n+ '/>'+
if not using indexOf , the name attribute is successfully thrown into the input form.
how ?