Justkez.com Ruby, Geospatial, Data-viz and life.


HTML Form Multiple Submit Buttons, Different Actions

Written on 28 Mar 2013 by Kester Dobson

I've often wondered as to the best way of having two form buttons that can submit but yield slightly different actions.  Turns out HTML5 scratches that itch with the `formaction` attribute.

The formaction attribute specifies the URL of a file that will process the input control when the form is submitted.

In my case, it's going to the same (Sinatra) controller action route, but by appending a simple URL parameter (`?action=this`) you can modify the response/control to change behaviour accordingly.

Simples

Check it out on W3Schools

Comments/Discussion

blog comments powered by Disqus --