I am trying to use a JavaScript variable in an HTML erb, using <% %> tags. query[i] is something I have in loop I am trying to call:
<%= Table.update('query[i]')%>;
How can I use query[i] from JavaScript for the actual value?
You can't do this. erb runs on the server to generate the HTML, which is then sent to the client, where the Javascript runs. By the time the Javascript variable is available, erb has already executed, and we're not even on the same machine anymore!
It looks as though you want Javascript code to supply a value which is then used as an argument to a database call. You'll have to do this via a post-back; i.e., the Javascript can make an AJAX call, a new erb could generate the new HTML fragment, and then the Javascript can receive it and plug it into the page.
Here's the first link I got when I googled "erb AJAX".
erb process has already completed, and you're on a completely separate machine. erb runs in your web server, and Javascript runs on the user's desktop. While erb is running, the Javascript variable doesn't exist yet.