I have three combos, which when loading the page combos 2 and 3 are disabled, until you select an option of combo 1 activates 2, and when choosing combo 2, activates 3.
What I want is to recover the value of the option that has been chosen and it already does, but I want to send that value to my Controller, but without clicking any button, simply by selecting the option, how can I do it?
I have this method in my controller which redirects me to the page where I have the combos, I made the class ObtieneInfoForm
with the attributes to retrieve the ids of the combos
@RequestMaping(value="/vista/formularioCombos", method=RequestMethod.GET)
public String muestraPantalla(Locale locale, Model model){
model.addAttribute("datosForm", new ObtieneInfoForm());
return "formularioCombos";
}
and this is my code in the jsp
<script>
function inhabilitaSelect(){
document.getElementById("#combo2").disabled=true;
document.getElementById("#combo3").disabled=true;
$("#combo1").change(function(){
var valor = $("#combo1").val();
if(valor >="1"){
$("#combo2").attr('disabled', false);
}
});
$("#combo2").change(function(){
var valor = $("#combo2").val();
if(valor >="1"){
$("#combo3").attr('disabled', false);
}
});
}
</script>
<form:form method="POST" modelAttribute="datosForm">
<select class="form-control" id="combo1" name="combo1">
<option value="0" selected>Elije una opcion</option>
<option value="1">Ejemplo1</option>
<option value="2">Ejemplo2</option>
</select>
<select class="form-control" id="combo2" name="combo2">
<option value="0" selected>Elije una opcion</option>
<option value="1">Ejemplo1</option>
<option value="2">Ejemplo2</option>
</select>
<select class="form-control" id="combo3" name="combo3">
<option value="0" selected>Elije una opcion</option>
<option value="1">Ejemplo1</option>
<option value="2">Ejemplo2</option>
</select>
</form:form>
What I do not know is how can I do that, get the value of the ids in my controller ?,
Is that the combos will be dependent to be filled with catalogs, that is, when selecting an option of combo 1, combo 2 will show only the options corresponding to what was chosen in combo 1, so that's why I want to recover the id of the first combo to pass as a parameter to the query and show in combo 2, that list already filtered and the same for combo 3