Passing data from Ruby to Javascript is easy, for example:
<script type="text/javascript">
    function change_value(val){
      alert ("<%= @alert %>")   
      }
    }
</script>
This will sent an alert with the data stored at the alert variable in the controller.
But I don't know how it works in the opposite direction, for example, if I need to store an element id into a controllers variable:
<script type="text/javascript">
    function change_value(element){
      <% @element_id = *** element.id *** %>
      alert ("<%= @element_id %>")   
      }
    }
</script>
The real deal is up next, the code surrended by *** are supposed to be the needed javascript values (@billeable_qts is a Hash):
<script type="text/javascript">
  function change_value(product){
    <% @billeable_qts[****product.id****] = ***document.getElementById('product.id').value****  %>
    <% @billeable_qts.each do |key, value| %>
       <% alert = "Key = " + key + ", value: " + value.to_s%>
       alert ("product: <%= alert %>")
    <% end %>
  }
</script>
