Most HTML forms have a hard-coded action URL that rarely needs to be changed. An action URL is nothing more than the URL where the form data will be processed. With the help of JavaScript, you can change the action URL before a visitor the form sends to the server. This technique can come in handy, if you know an action URL before. You can use this coding technique to show the change in an E-Mail form to the URL in response to an input from the user.
What you Need
the HTML Editor
- Create a new HTML document and add the following form code to the body of the document: By: This form to send an E-Mail to the specified URL in the action parameter. Since this URL is empty, the E-Mail process will fail. It is dynamically determined to provide the URL via JavaScript, the missing URL. the
- , Add an HTML button below the form using this code:
- Create a \ " \ " - section in the document and add the following JavaScript function: function setFormURL() { var sendToURL = \"xyz\" GO-to document.the test form.action = \"mailto:\" sendToURL GO } in This function, the action URL of the form to the specified value in the variable with the name \"sendToURL\". Set the value of the URL of a known E-Mail account that you have. the
- Test HTML page in your browser. If you click on the \"Set E-Mail-URL\" button, the JavaScript function change the action URL of the form to the value that you specified in the function. When you submit the form, the browser sends an E-Mail to this E-Mail address.
Form Action with JavaScript, change
Most HTML forms have a hard-coded action URL that rarely needs to be changed. An action URL is nothing more than the URL where the form data will be processed. With the help of JavaScript, you can change the action URL before a visitor the form sends to the server. This technique can come in handy, if you know an action URL before. You can use this coding technique to show the change in an E-Mail form to the URL in response to an input from the user.
What you Need
the HTML Editor
- Create a new HTML document and add the following form code to the body of the document: By: This form to send an E-Mail to the specified URL in the action parameter. Since this URL is empty, the E-Mail process will fail. It is dynamically determined to provide the URL via JavaScript, the missing URL. the
- , Add an HTML button below the form using this code:
- Create a \ " \ " - section in the document and add the following JavaScript function: function setFormURL() { var sendToURL = \"xyz\" GO-to document.the test form.action = \"mailto:\" sendToURL GO } in This function, the action URL of the form to the specified value in the variable with the name \"sendToURL\". Set the value of the URL of a known E-Mail account that you have. the
- Test HTML page in your browser. If you click on the \"Set E-Mail-URL\" button, the JavaScript function change the action URL of the form to the value that you specified in the function. When you submit the form, the browser sends an E-Mail to this E-Mail address.
Form Action with JavaScript, change
By Howtodotips
Most HTML forms have a hard-coded action URL that rarely needs to be changed. An action URL is nothing more than the URL where the form data will be processed. With the help of JavaScript, you can change the action URL before a visitor the form sends to the server. This technique can come in handy, if you know an action URL before. You can use this coding technique to show the change in an E-Mail form to the URL in response to an input from the user.