I have created an HTML form and when I click a button I want to call a ruby function. The HTML form has a text field and and dropdown menu and their values should be given as input parameters to the ruby function.
The ruby function is the following:
def price(amount, item)
# code here
end
I tried to do something like this, but it is obviously wrong:
fileHtml.puts " <script>
function calculatePrice(){
document.getElementById('price').value = <% object = MyClass.new %>
<%= object.amount(document.getElementById('amount').value, document.form.menu.options[document.form.menu.selectedIndex].value) %>
}
</script>"
How could I pass the value of the text field to the "amount" and the value of the dropdown menu to the "item" parameter of the ruby function?