I want to set some variables getting they from the values of 5 select elements, the multiselect IDs have the same name that the variable names in the script....
Inside HTML part:
<select id="variable1">
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>
<select id="variable2">
<option value="algo1">algo1</option>
<option value="algo2">algo2</option>
<option value="algo3">algo3</option>
</select>
<!-- etc -->
and in the jQuery script:
var variable1;
var variable2;
var variable3;
var variable4;
var variable5;
$("#variable1, #variable2, #variable3, #variable4, #variable5").change(function(){
var valorAcambiar = $(this).attr('id');
valorAcambiar = $(this).val();
});
So I'm trying this, but doesn't work... I think the problem is that the script is not running the selected strings values from the ID attr of the select elements as variable names for the script, some one could please help me?
I mean, I want that "valorAcambiar" takes the name of variable1 (coming from id attr of select element) or any other, to change global variable1 (or any other) value in the script.
So I can get variable1 = 20 for example if someone changes variable1 select, or variable2 = algo3 for example if someone changes variable2 select, and this for the 5 multiselect elements.
Thanks.