Welcome, Guest
Username: Password: Remember me

TOPIC: Posting page URL in Hidden Field

Posting page URL in Hidden Field 10 years 11 months ago #5701

  • Juha
  • Juha's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
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-
The administrator has disabled public write access.

Posting page URL in Hidden Field 10 years 11 months ago #5716

  • Administrator
  • Administrator's Avatar
  • OFFLINE
  • Administrator
  • Posts: 795
  • Thank you received: 64
Dear Juha,

Please try move that code in to before_load() function.
If the problem persist, please give us (to This email address is being protected from spambots. You need JavaScript enabled to view it.) 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
The administrator has disabled public write access.

Posting page URL in Hidden Field 10 years 11 months ago #5877

  • Juha
  • Juha's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
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-
The administrator has disabled public write access.
The following user(s) said Thank You: Dwi Ade Riandayani

Posting page URL in Hidden Field 10 years 6 months ago #9461

  • Papay
  • Papay's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
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!
Last Edit: 10 years 6 months ago by Papay.
The administrator has disabled public write access.

Posting page URL in Hidden Field 10 years 6 months ago #9465

  • Administrator
  • Administrator's Avatar
  • OFFLINE
  • Administrator
  • Posts: 795
  • Thank you received: 64
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.
Last Edit: 10 years 6 months ago by Administrator.
The administrator has disabled public write access.

Posting page URL in Hidden Field 9 years 5 months ago #23126

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 !
The administrator has disabled public write access.

Posting page URL in Hidden Field 9 years 5 months ago #23149

  • Support
  • Support's Avatar
  • OFFLINE
  • Moderator
  • Posts: 10443
  • Thank you received: 633
Dear Patrick,

Please give us direct link to your form.
Best regards
Web-Dorado team

Joomla extensions,
Wordpress plugins,
Drupal modules
Clear the cache before asking questions. :)
The administrator has disabled public write access.

Posting page URL in Hidden Field 9 years 4 months ago #24300

  • Evelien
  • Evelien's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
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?
Last Edit: 9 years 4 months ago by Evelien. Reason: been more specific
The administrator has disabled public write access.

Posting page URL in Hidden Field 9 years 4 months ago #24336

  • Support
  • Support's Avatar
  • OFFLINE
  • Moderator
  • Posts: 10443
  • Thank you received: 633
Dear Evelien,

Could you please contact us to This email address is being protected from spambots. You need JavaScript enabled to view it. 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
Clear the cache before asking questions. :)
The administrator has disabled public write access.

Posting page URL in Hidden Field 9 years 4 months ago #24367

  • Evelien
  • Evelien's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
send you the mail. Thanks for helping out.
The administrator has disabled public write access.

Posting page URL in Hidden Field 9 years 4 months ago #24392

  • Support
  • Support's Avatar
  • OFFLINE
  • Moderator
  • Posts: 10443
  • Thank you received: 633
Dear Eveline,

We received your email.
Best regards
Web-Dorado team

Joomla extensions,
Wordpress plugins,
Drupal modules
Clear the cache before asking questions. :)
The administrator has disabled public write access.
Time to create page: 0.548 seconds
Powered by Kunena Forum