I have the classic issue where I have two select boxes, the second's
contents dependent on the first. I found some same code that works
fairly well using an Ajax.Updater. However, I need to pass in the
selected value of the original select list to the ajax call. I am
trying to use this[this.selectedIndex].value but keep getting a
"undefined local variable or method `this' for #<#<Class:0x3143860>:
0x3143838>".
Any ideas? Here's a my snippet of code from my view.
Your onChange parameter must be a string that will be evaluated
client-side. The way your wrote it, you are calling this on the Rails
View object, which is the error you are getting.
You must either: escape your quotes, or use the %Q() operator to
enable you to use quotes inside a string, without escaping:
:onChange => %Q(
new Ajax.Updater('categories_span', '/mgs/department_changed/' +
this[this.selectedIndex].value, {asynchronous:true, evalScripts:true)