I have an HTML form on the screen, that is connected to a database
(standard Ruby way). I found that there are people that would rather not
fill in this information, but would rather search Amazon for the info.
Therefore, I added a link to the right of one of the fields that, when
pressed, will search Amazon for what ever you typed into that field.
So, how can I do that? At first I tried adding a line to the link’s
function in my controller, where I get the value of the “book” by doing
@test = params[:book]. Similar to the way that ‘create’ does it; but,
remember, I don’t want to save this book yet, so I don’t do everything
that create does. This always gives me a blank hash value, leading me to
believe that the hash hasn’t been stored yet, because nobody pressed the
“Create” button.
So the next thought is to actually pass in the value when you press the
link, along the lines of:
<%= link_to(“Lookup by title”, :action => ‘lookup_by_title’, :val =>
fieldValue) %>
But how do I get the contents of the field? In JavaScript I’d do
document.formName.fieldName.value, but I can’t do that here because 1.
what is the name of this form? and 2. If I simply say document. blah
blah blah, Ruby barfs because it doesn’t know what document is.
Any thoughts?