Re: Accessing form elements

Pardee, Roy
Thu, 05 Jun 2008 00:46:15 -0000

So you''ve got a traditional form generated by form_for, with the
expected submit button etc.  That all works just as you want it to.  Now
you want to *in addition to the existing submit button* offer a link up
at the top of the page that will submit that same form.  Do you want
that link to a) have exactly the same effect as the submit button--no
more, no less, or b) have the same effect as the submit button *plus*
tack an extra parameter & value onto :params?  (Or c) something else?)

If a)--I would think Fred''s earlier suggestion to use javascript to do
a
my_form.submit() should work.  I don''t know the best way to get rails
to
generate that (link_to_function("click me",
"my_form.submit()") maybe?)
but no doubt others here will.  If b) it''s probably a little more
involved (javascript stuffs your parameter in a hidden field created in
your form maybe, and *then* does a my_form.submit()?).

HTH,

-Roy

-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of
Chris Hickman
Sent: Tuesday, June 03, 2008 3:47 PM
To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: [Rails] Accessing form elements


I posted a question earlier but it didn''t come out that clear and I
have
spent the whole day looking this up.  Any help would be much
appreciated.

Here goes round 2:

I have several textareas on the screen (anywhere from 1 - 5).  Right now
I have them in a form and am using a submit button to pass the values to
the controller.  What I need to do is pass these values to the
controller using links located outside of the actual form.  When the
link is click the values from the textareas are passed to the controller
along with a :question parameter. The values of the textareas are saved
into the db and the :question param is used in a query and then the page
is redirected to another page with the result from the query as another
param.

The part I cannot seem to find an answer for is how to pass the values
of the textareas to the controller using  link_to(), not link_to_remote.
Or how do you access the textarea values and attach them to :value1 =>
????


I really hope that made more sense.

Thanks,

Chris
--
Posted via http://www.ruby-forum.com/.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com