-1
The goal is popular a select according to the previous select.
Script
<script>
$(function () {
$('#adms_grps_prod').change(function () {
if ($(this).val()) {
$('#adms_tps_prod').hide();
//console.log('tipo ocultado');
$.get('../outros/tps_prods?search=', {adms_grps_prod: $(this).val(), ajax: 'false'}, function (j) {
var options = '<option value="">Escolha o Tipo</option>';
//console.log(options);
for (var i = 0; i < j.length; i++) {
//options += '<option value="' + j[i].id + '">' + j[i].nome + '</option>';
//alert(j[i]);
console.log("Script: " + j);
}
$('#adms_tps_prod').html(options).show();
$('.carregando').hide();
});
} else {
console.log('Ocorreu um erro!');
}
});
});
</script>
With the above script, I got the following result:
<!DOCTYPE html>
<html lang="pt-br">
<pre class='xdebug-var-dump' dir='ltr'>
<small>C:\wamp64\www\site_delivery\adm\app\cpadms\outros\tps_prods.php:33:</small><small>string</small> <font color='#cc0000'>'1'</font> <i>(length=1)</i>
</pre>ID: 1[{"id":"2","nome":"Cerveja Devassa 600ml"},{"id":"1","nome":"Cerveja Heineken 600ml"}]</html>
How do I get only the ID?
Had already done this way, but presented "Undefined".
– Ronald Anjos