# Form question

**URL:** <https://www.ruby-forum.com/t/form-question/138290>\
**Category:** Rails\
**Created:** [May 21, 2008, 6:17pm UTC](https://www.ruby-forum.com/t/form-question/138290 "2008-05-21T18:17:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 21, 2008, 6:17pm UTC](https://www.ruby-forum.com/t/form-question/138290/1 "2008-05-21T18:17:54Z")

</div>

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,

Chris

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 21, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/form-question/138290/2 "2008-05-21T21:16:53Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 21, 2008, 9:20pm UTC](https://www.ruby-forum.com/t/form-question/138290/3 "2008-05-21T21:20:34Z")

</div>

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.
