How to get Element value by calling JS function in Rails Controller

Viewed 20

I have an element in my view and I want it's value. I can get it in a javascript file, but I need it in my controller to make a SQL query.

How do I call that JS function from my Rails controller and get the return value?

My JS file looks like this:

  function getAmountOrdered(){
    var amountOrdered = document.getElementById('order_amount_ordered').value;
    return amountOrdered
  }

and Rails controller:

def index
  amount_ordered = ????
  some more stuff...
end

What do I have to write where the ???? are?

0 Answers
Related