Javascript function needs rails variable

I have implement this but rails variables are not working.

This will only work if that script block is in an .erb template.

it starts working
Cheers
Rabia Akhtar