I have select
with some mobile operators:
<select name="valor" id="operadoraRecarga" class="form-control operadoraRecarga">
<option value="claro">Claro</option>
<option value="tim">Tim</option>
<option value="oi">Oi</option>
<option value="vivo">Vivo</option>
<option value="nextel">Nextel</option>
</select>
And I have an array list with each operator's reload values
var claro_array = new Array('10.00', '13.00', '15.00', '20.00', '30.00', '50.00', '100.00');
var vivo_array = new Array('5.00', '10.00', '15.00', '20.00', '25.00', '35.00', '100.00');
var oi_array = new Array('10.00', '14.00', '18.00', '20.00', '25.00', '30.00', '35.00', '40.00', '50.00', '75.00', '100.00');
var tim_array = new Array('7.00', '15.00', '20.00', '30.00', '35.00', '50.00', '100.00');
var nextel_array = new Array('20.00', '30.00', '50.00', '100.00');
I have the code below where according to what was selected in select
it already selects the right array to mount the other select
of values, but the problem is that instead of doing so it is catching each letter of the word (ex: tim_array) and mounting the select, getting each option type like this:
Option 1: t
Option 2: i
Option 3: m
My Code
jQuery(document).ready(function($){
var claro_array = new Array('10.00', '13.00', '15.00', '20.00', '30.00', '50.00', '100.00');
var vivo_array = new Array('5.00', '10.00', '15.00', '20.00', '25.00', '35.00', '100.00');
var oi_array = new Array('10.00', '14.00', '18.00', '20.00', '25.00', '30.00', '35.00', '40.00', '50.00', '75.00', '100.00');
var tim_array = new Array('7.00', '15.00', '20.00', '30.00', '35.00', '50.00', '100.00');
var nextel_array = new Array('20.00', '30.00', '50.00', '100.00');
$("#operadoraRecarga").change(function(){
var selecionado = $("#operadoraRecarga option:selected").val();
var nome_array = selecionado+'_array';
var html = '';
$("#valorRecarga").find('option').remove();
for(i = 0; i <= nome_array.length; i++){
html += '<option value="'+nome_array[i]+'">'+nome_array[i]+'</option>';
}
$("#valorRecarga").append(html);
})
});