- MineshAsked 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.
- JotForm SupportNeilVicenteAnswered on July 17, 2012 at 08:40 PM
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).
- JotForm SupportjonathanAnswered on July 17, 2012 at 08:46 PM
<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.
- ;,,Answered on January 18, 2016 at 03:25 AM