Hello, I'm trying to populate 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 do not know if I'm doing it properly.
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 particular select, I give $.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 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 make it popular with this result, select with id curso_nome
?
I hope you have explained my question well.