Clear Button

16 views
Skip to first unread message

Jan Yo

unread,
Mar 31, 2014, 2:32:18 PM3/31/14
to rubyonra...@googlegroups.com
Using Rails 4. I have a text_area_tag with submit_tag to do a query. I
need to add a button to clear out the textarea and resubmit the form
(using form_tag)

Layout looks like this:
Textarea
Query Button 1 Clear Button

Code looks like this:
form_tag ....
text_area_tag
submit_tag "Query Button"
end form tag

Any ideas? Ajax was suggested.

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

Hassan Schroeder

unread,
Mar 31, 2014, 3:05:11 PM3/31/14
to rubyonrails-talk
On Mon, Mar 31, 2014 at 11:32 AM, Jan Yo <li...@ruby-forum.com> wrote:
> Using Rails 4. I have a text_area_tag with submit_tag to do a query. I
> need to add a button to clear out the textarea and resubmit the form
> (using form_tag)
>
> Layout looks like this:
> Textarea
> Query Button 1 Clear Button
>
> Code looks like this:
> form_tag ....
> text_area_tag
> submit_tag "Query Button"
> end form tag
>
> Any ideas? Ajax was suggested.

?! Why would you want to submit an empty form?

Regardless, just create another submit button with an onsubmit
handler to set the textarea value to "".

But I still can't imagine your use case...

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Reply all
Reply to author
Forward
0 new messages