Send URL of page the form was submitted on
Wayne Gowers created the topic: Send URL of page the form was submitted on
Hi We'd like a simple "Request info" button for a web catalog. We need the url of the page that the button was pressed on to appear in the email that was sent.
How do I include the page url in the info emailed with the form?
Please Log in or Create an account to join the conversation.
- Topic Author
- Wayne Gowers
- Offline
- Fresh Boarder
- Posts: 7
- Thank you received: 0
8 years 2 months ago
Agapi G. replied the topic: Send URL of page the form was submitted on
Dear Wayne,
You will need to write a few lines of jQuery code in Form Options > Javascript tab to get the page URL. Also, please place a hidden field, to which the code will add the link.
Here's the approximate code you will need to use:
var pathURL = location.pathname;
jQuery('#hidden_field_id').val(pathURL);
Where hidden_field_id is the exact ID of your hidden field. You can get it from frontend of your form, using developer tools of your browser.
Thank you!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
8 years 2 months ago
andrey replied the topic: Send URL of page the form was submitted on
I created hidden field
Field Name : pathURL
Field Value : pathURL
Find out the hidden_field_id "wdform_7_element1", using developer tools of my browser.
Open Form Options > Javascript and place the code
// Occurs before the form is loaded
function before_load()
{
var pathURL = location.pathname;
jQuery('wdform_7_element1').val(pathURL);
}
// Occurs just before submitting the form
function before_submit()
{
}
// Occurs just before resetting the form
function before_reset()
{
}
The result I received after submitted a form:
E-mail: [email protected]
Message: TEST
pathURL pathURL
So, the page URL was not shown up.
What did I do wrong ?
Please Log in or Create an account to join the conversation.
8 years 2 months ago
Agapi G. replied the topic: Send URL of page the form was submitted on
Dear Andrey,
Firstly, make sure to leave the Value option of your hidden field blank. This way only the URL will be written with Javascript, but in case you write something, it might keep it and make it look weird.
And secondly there is a small mistake in your jQuery code. You forgot to add # sign before your hidden field ID. Please do that, so the code looks like this:
var pathURL = location.pathname;
jQuery('#wdform_7_element1').val(pathURL);
Thank you!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
8 years 2 months ago
Michael Hill replied the topic: https://mlc-cad.biz/home/industries
For the life of me I can't find out the correct ID for the hidden field using Google's developer's tools. Can you please assist me? The hidden pathURL field is after the message and before ReCaptcha
mlc-cad.biz/home/industries
Please Log in or Create an account to join the conversation.
- Michael Hill
- Offline
- Fresh Boarder
- Posts: 1
- Thank you received: 0
7 years 8 months ago
Agapi G. replied the topic: https://mlc-cad.biz/home/industries
Hi Michael!
Thank you for posting your request! The ID of your hidden field is #wdform_20_element12 so the code for your form would be:
var pathURL = location.pathname;
jQuery('#wdform_20_element12').val(pathURL);
Thank you! Have a great day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
7 years 8 months ago