1
Hello, I’m trying to popular a select with the options that are returned, according to what the user selects in a particular select. The problem is that I’m a layman with jquery and I don’t know if I’m doing it correctly.
In my select I call the function with the onchange event:
<?=$this->Form->input('escola_id',array('class'=>'formcontrol','onchange'=>'MostraPrograma(this.value)'));?>
As I just want to treat this specific select, I give a $.post
in a url where it does the query according to the selected option.
function MostraPrograma(_a){
$.post('/novas/mostra_programa/'+_a), $("#CursoNewAddForm").serialize(),function(data){
}
}
and in my view I do this:
echo '_tipos_de_programa = ' . json_encode($info_campus).';';
and in my console returns me this array:
_tipos_de_programa = [{"CursoCampus":{"id":"21","nome":"Curso Geral 35 aulas 221232"}},{"CursoCampus":{"id":"22","nome":"Curso Geral 35 aulas 221"}},{"CursoCampus": {"id":"23","nome":"Curso Geral 25 aulas12323"}}];
Now how do I popular with this result, select with id curso_nome
?
I hope you explained my doubt well.