0
I am using a form to register dynamic questions in my system. I’m also recording this data in a session so I don’t have to be selecting all the time dropdows but there’s a problem:
In the Submit, in the field Select a category: i take the category ID in the session and auto-select with PHP and give a Trigger with jQuery so that, through the category ID, it consult the database and fill the field dropdown Select an activity from: ...
Now comes the bullshit: I want to leave selected too Activity because are several questions for the same Category and Activity.
When loading, the system picks up the ID selected in Category and consults on Activity. What I have so far are two ID’s in a Session (PHP) and the jQuery code below:
$(document).ready(function() {
var param = $("#categoriaCad option:selected").val();
$.ajax({
url: CAMINHO_JAVASCRIPTI+"/usuarios/ajaxsubcat",
type: "POST",
dataType: "json",
data: {param: param},
success: function(data){
$('#cadSubcategoria').find('option').remove().end().append('<option value="">Selecione uma categoria ...</option>');
$.each(data, function(chave, valor) {
$('#cadSubcategoria').append($('<option>').attr('value', valor.id).text(valor.atividade));
});
}
});
});