Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a form's action attribute when submitting?

How do I change a form's action attribute right after clicking the submit button?

like image 562
dave Avatar asked Apr 12 '11 20:04

dave


People also ask

How you use form's action attribute and submit button in HTML?

Definition and Usage The formaction attribute specifies where to send the form-data when a form is submitted. This attribute overrides the form's action attribute. The formaction attribute is only used for buttons with type="submit" .

What should I put in a form action attribute?

The HTML | action Attribute is used to specify where the formdata is to be sent to the server after submission of the form. It can be used in the <form> element. Attribute Values: URL: It is used to specify the URL of the document where the data to be sent after the submission of the form.

What is the purpose of a form's action attribute?

The HTML form action attribute defines what should happen to data when a form is submitted on a web page. The value of the action attribute should be the URL of the web resource that will process the contents of the form.


1 Answers

<input type='submit' value='Submit' onclick='this.form.action="somethingelse";' /> 

Or you can modify it from outside the form, with javascript the normal way:

 document.getElementById('form_id').action = 'somethingelse'; 
like image 60
James Avatar answered Sep 20 '22 08:09

James