How to add different submit behaviors to buttons?


I have a form with fields which the user can write in and also some buttons. One cancel button and two save. One of the save buttons has to reload the page after the content has been submitted and the other has to take the user to another page, let's say google. The problem is that the button can take the user to another page or save the content. The code below doesn't save the form, it only takes the user to google. How can I solve this issue?

   <form id="saveButtonAndGo" action="www.google.com">
    <input type="submit" name="submit" value="saveButtonAndGo">
   </form>

---------------Answer---------------

Submit the form to your form handler.

Test the value of the submit field in the submitted data (only the clicked submit button will be a successful control).

If you want to redirect the user to Google after processing their data, do it by having your server side code emit an HTTP redirect (i.e. a 302 status and a Location header).


Previous : How to send logs from a heroku app to grafana cloud?
Next : How can i use an format for Datepicker on java