Form question

I am guessing this is an easy question, I just can’t seem to find out
how to do it.

I have created an online assessment for kids. There are apprx. 20
different sections each having several questions. I have all the
navigation from question to question and section to section in the
layout file. One of the templates I am rendering needs to have a form
in it. How can I submit the data from the form when the user clicks the
navigation in the layout rather than having them click a submit button
and then the navigation button.

All of the different helpers I have been looking at use the submit
button to submit the data.

Thanks in advance,


Try using a link_to_function (or the underlying onclick event). For
your function, use remote_function(:url=>someplace-to-store-
answers_path, :method=>:post, :submit=>‘dom-id-of-section’). That
should submit the ‘form’ via ajax.

I think that link_to_function may append “return false” to the end of
the javascript that you provide, with the result that processing of
the click even will stop. If that’s the case then you may need to add
some additional javascript to assist with the dom navigation. Another
option is to stick with onclick which will allow you full control over
the function; if you don’t return false then you should fall through
to the default processing after issuing the ajax request.

On May 21, 12:17 pm, Chris H. [email protected]

The way it is “working” right now is with ajax. I have a bunch of text
areas and I was trying to submit the data using remote_function(). Then
I tried to use onblur and onunload to submit the data. The problem is
is works about 15% of the time, not consistent at all. I was trying to
stay away from the ajax and javascript stuff all together if possible.
Thanks for the feedback though.