In my edit.html.erb I'm using some javascript mixed with some ruby code:
var sel = document.getElementById("right").;
var len = sel.options.length;
var str = "";
for (var i = 0; i < len; i++)
{
if(sel.options[i].selected)
{
<% RHoliday.find_or_create(holiday_id: sel.options[i].value , group_id: @group.id ) %>
}
}
}
But I always get the following error:
undefined local variable or method `sel' for #<#:0x3f90ee8>
It's because I'm trying to access a variable from my javascript. My question is: Is there a way to get around this error?