Posting page URL in Hidden Field

Juha created the topic: Posting page URL in Hidden Field

Hi guys,

I'm using same the same form in multiple pages and I'd like to pass page URL via hidden field so that we can track where on our site people fill in the form.

I tried to add this code in the "edit javascript" -part:

document.getElementById("hidden-element-id-from-the-form").value=document.location.href;

Unfortunately this breaks the form and the submit button doesn't work after this mod.

Would you be able to help me out with this?

cheers,
-juha-

#5701

Please Log in or Create an account to join the conversation.


Administrator replied the topic: Posting page URL in Hidden Field

Dear Juha,

Please try move that code in to before_load() function.
If the problem persist, please give us (to [email protected]) a link to your site and temporary admin user account, and we will try to find out the problem and fix it as soon as possible.

Best regards
Web-Dorado team

#5716

Please Log in or Create an account to join the conversation.


Juha replied the topic: Posting page URL in Hidden Field

Thank you for quick reply. This worked perfectly.

To help others make this happen a bit quicker pls find the code below that i used via edit Javascript

// before form is load
function before_load()
{
document.getElementById("7_element2").value=document.location.href;
}	
// before form submit
function before_submit()
{
}	
// before form reset
function before_reset()
{	
}
The"document.getElementById()" part needs to be edited for every form manually by adding the ID of the hidden field in it.

You can find the ID by editing/creating a hidden field (correct ID is titled "Field ID"). Note that You can't paste this ID directly to Javascript. It needs to be edited a bit.

For example in my case Form Maker showed the ID as "7_elementform_id_temp" The bold part needs to be amended manually --> just delete that part and add the number of the form there and it should work perfectly. In my case it was the form #2 so I changed it to "7_element2".

Hope this helps others who have similar issues with passing the form URL to database.

cheers,
-juha-

#5877
The following user(s) said Thank You: Dwi Ade Riandayani

Please Log in or Create an account to join the conversation.


Papay replied the topic: Posting page URL in Hidden Field

I'm confused with the document.getElementById() part. I already created a new form [Form id="10"]. This is the steps I made afterwards:

1. Clicked on Add New Field
2. Selected Text Input
3. Ticked Hidden Field

I was about to Save it but received an error (the name of the field is required)

Can I input anything on the Field Name? ( I tried to input Page URL as Field Name)

Also in the field ID its output is 8_elementform_id_temp

I also tried replacing 8_elementform_id_temp to 8_element10 but still Page URL column on my Submissions page is empty

Is there something I'm doing wrong here? Thanks in advance!

#9461

Please Log in or Create an account to join the conversation.


Administrator replied the topic: Posting page URL in Hidden Field

Dear Papay
First, you should put something in the "Field Name" before saving. Please use PageURL (without space) instead of Page URL.

You can use the field ID 8_elementform_id_temp in the javascript. This will be automatically recognized and replaced.

Best regards
Web-Dorado team

P.S. As Juha explained, the field ID is 8_elementform_id_temp on the back end (admin). On the front end form_id_temp will be replaced by the form ID (i.e. 8_element10 if your form ID is 10) both in the html and js.

#9465

Please Log in or Create an account to join the conversation.


Patrick St-Cyr replied the topic: Posting page URL in Hidden Field

Field Id: wdform_9_elementform_id_temp
Field Name: PageURL

What I put in "before_load" javascript:
function before_load()
{
document.getElementById("wdform_9_elementform_id_temp").value=document.location.href;
}

Does not work ;(

Help please !

#23126

Please Log in or Create an account to join the conversation.


Support replied the topic: Posting page URL in Hidden Field

Dear Patrick,

Please give us direct link to your form.


Best regards,
Web-Dorado team


Joomla extensions ,
Wordpress plugins ,
Drupal modules
#23149

Please Log in or Create an account to join the conversation.


Evelien replied the topic: Posting page URL in Hidden Field

this was working great, but somehow after an update it stopped working correctly. The PageURL is put into the e-mail, but not into the database anymore. Strange.

Looking at the source of the page that has my form, it says:

<script type="text/javascript">// before form is load
function before_load() {
     document.getElementById("wdform_13_element11").value=document.location.href;
}

// before form submit
function before_submit() {
}

// before form reset
function before_reset() {
     
}</script>

and within the form:
<input type="hidden" value="" id="wdform_13_element11" name="PageURL" >


What's the solution?

#24300

Please Log in or Create an account to join the conversation.


Support replied the topic: Posting page URL in Hidden Field

Dear Evelien,

Could you please contact us to [email protected] and let us to take a look at the issue? Please mention the full link to your forum post in your e-mail.Also please include temporary admin credentials to your website in the mail.

Thank you


Best regards,
Web-Dorado team


Joomla extensions ,
Wordpress plugins ,
Drupal modules
#24336

Please Log in or Create an account to join the conversation.


Evelien replied the topic: Posting page URL in Hidden Field

send you the mail. Thanks for helping out.

#24367

Please Log in or Create an account to join the conversation.


Support replied the topic: Posting page URL in Hidden Field

Dear Eveline,

We received your email.


Best regards,
Web-Dorado team


Joomla extensions ,
Wordpress plugins ,
Drupal modules
#24392

Please Log in or Create an account to join the conversation.


richard replied the topic: Posting page URL in Hidden Field

so what was the solution?

#47175

Please Log in or Create an account to join the conversation.


Agapi G. replied the topic: Posting page URL in Hidden Field

Dear Richard,

You can get the URL written in a Hidden Field the following way. You need to write a few lines of jQuery code to Form Options > Javascript. The approximate code is the following:

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 by inspecting the element with developer tools of your browser.

Thank you!


Kind regards,
Agapi G.
Web-Dorado team
#47243

Please Log in or Create an account to join the conversation.


Time to create page: 0.249 seconds
Powered by Kunena Forum

WORLD-CLASS SUPPORT

We are here for you every step of the way. Turn to our support with any questions you might have about our products and services. Our experienced customer care team is available to help you as fast as we possibly can.

Contact us