What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.
At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.
We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.
Get current url and set as hidden field valueAsked by Minesh on July 17, 2012 at 08:15 PM
I have a hidden field in my form. I have embedded this form in my website, and I need to get current url and set this url as value in my hidden field.
In order to do this, I have set as default value in my hidden field a php instruction: <?php echo $_SERVER['REQUEST_URI']; ?>.
Unfortunatly, when i submit the embedded form this hidden field appears blank.
How can I obtain current URL and submit as the value of the hidden field?
Thanks in advance.
The form itself is an HTML page, not a PHP one, so it cannot execute PHP functions. Therefore, setting a PHP function as your hidden field's default value will not work.
If the page where you have embedded the form is a php file, it is better to prepopulate the form with that php function using URL parameters.
Try the codes below:
<iframe allowtransparency="true" src="//form.jotform.co/form/21806958155865?hagaClic21=<?php echo $_SERVER['REQUEST_URI']; ?>" frameborder="0" style="width:100%; height:560px; border:none;" scrolling="no">
Please note that you will have to remove the hidden field's default value first (via JotForm).
<input type="hidden" class="form-hidden" value="" id="input_10" name="q10_myurl" />
document.getElementById('input_10').value = document.URL;
</script>input_10 is the hidden field.I thought I should also share. More selection option is better =)Thanks.