I have a hash "c_failures_all" with some values in it and i am capturing value of selected item from a dropdown list in variable "selVal" using jquery. That "selVal" will act as a key in my hash. The problem is selVal is a jquery variable and if do
c_failures_all[selVal]
throws an error "undefined local variable or method `selVal' for #<#:0x15484300>"
c_failures_all = {"Amount"=>[5, 4, 8, 7, 6], "Lookup"=>[10, 85, 56, 23, 10], "Advantage"=>[9, 5, 40, 12, 3]}
<script>
$("#error_error_id").on('change', function(){
//alert('f')
var selVal = $("#error_error_id").val();
if(selVal == "All" || selVal == '')
{
options.series = [{name: 'All', data: <%= c_failures_arr %>}]
}
else
{
options.series = [{name: 'D', data: <%= c_failures_all[selVal] %>}]
}
var chart = new Highcharts.Chart(options);
});
</script>