This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Passing a URL into a hidden field
Started 14 years ago by jccj45 | 16 posts |
-
Is there anyway for my form to capture the webpage (URL) it was submitted from. This would be a great feature when running different ad campaigns.... i.e. www.abc-widgets.com/item1 I would love to see this URL (or item1) inside my form that was submitted.
Posted 14 years ago # -
It's possible to parse the url variable into your form field. To do this, you can use the method that posted in here :
http://www.appnitro.com/forums/topic/adding-hidden-variables-to-machforms#post-5131
or
http://www.appnitro.com/forums/topic/dynamic-content-php?replies=12
Then you can put this css code into your form to hide the field
#li_1 { display:none !important; }
Don't forget to change the id's with yours
MachForm Support
Posted 14 years ago # -
Hi, did you get this figured out? I have looked at the two suggested posts and can't for the life of me see what I need to do?
Any help would be appreciated.
Regards
RichardPosted 13 years ago # -
This confused me too. Im looking for a way to see if my form has been filled out on my website or on my Facebook page. Its the same form but visible from two places.
I was thinking the best way to do what I want is to repopulate a hidden field with either a predefined value (such as "Facebook") or the URL of the page used to access the form. (But this might be tricky as my Facebook page accesses the forms direct URL through an iFrame.
any help would be great.
Posted 13 years ago # -
I am changing from a system where i am using a variable "pname" which I would like to continue using with MachForm.
This shows up in the url like this: http://www.atlantarex.com/contact.php?pname=Marietta-Square-Restaurant-for-Sale
I want to pass the variable to a form on a page in my root directory which is on this page: http://www.atlantarex.com/contact.php
Here is the code for the field that I want to pre-populate:
</li> <li id="li_8" > <label class="description" for="element_8">Property </label> <div> <input id="element_8" name="element_8" class="element text medium" type="text" value="" /> </div> and: <form id="form_2">
Best regards,
DougPosted 12 years ago # -
Hi Doug,
I see that you are using the javascript embed code for version 3.
<script type="text/javascript"> var __machform_url = 'http://atlantarex.com/machform/embed.php?id=2'; var __machform_height = 763; </script>
Try to change it with this one:
<script type="text/javascript"> var __machform_url = 'http://atlantarex.com/machform/embed.php?id=2<?php echo '&element_8='.$_GET['pname']; ?>'; var __machform_height = 763; </script>
MachForm Founder
Posted 12 years ago # -
Perfect! thanks for the great customer service!
Posted 12 years ago # -
I am trying to do something similar, but since this question has been answered, it seems the js embed method is a bit different. I am using mach forms 3.4, the lates version.
I have a text field (hidden with css, #li_5). I'm trying to set the value of this field with the url like this:
<script type="text/javascript"> var __machform_url = 'http://xcitemediaforms.com/embed.php?id=59210<?php echo '&element_5='.$_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; ?>'; var __machform_height = 637; </script> <div id="mf_placeholder"></div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/jquery.ba-postmessage.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/machform_loader.js"></script>
The above code doesn't work at all - the form just doesn't show up.
When I change the code to a simple string for the url parameter 'element_5=test' (below) it works fine. Is there a way to get the URL, as I am trying in the first snippet with PHP?
<script type="text/javascript"> var __machform_url = 'http://xcitemediaforms.com/embed.php?id=59210&element_5=test'; var __machform_height = 637; </script> <div id="mf_placeholder"></div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/jquery.ba-postmessage.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/machform_loader.js"></script>
Posted 11 years ago # -
Those code snippets should be the same. Try to check the generated code on your browser when you are using the PHP snippet above, is the code the same as the simple string code?
Also, you might need to enclose the URL with urlencode, like this:
var __machform_url = 'http://xcitemediaforms.com/embed.php?id=59210<?php echo '&element_5='.urlencode($_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]); ?>';
MachForm Founder
Posted 11 years ago # -
So the problem was me trying to get the SERVER_NAME as well as the URI. Any ideas why this would block the form from loading?
It works fine with the code below. Notice I'm just grabbing the URI and not the SERVER_NAME
<script type="text/javascript"> var __machform_url = 'http://xcitemediaforms.com/embed.php?id=59210<?php echo '&element_5='.urlencode($_SERVER["REQUEST_URI"]); ?>'; var __machform_height = 637; </script> <div id="mf_placeholder"></div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/jquery.ba-postmessage.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/machform_loader.js"></script>
Thanks for the help!
Posted 11 years ago # -
Is it possible for you to post the URL of the page where you embed the form? So that we could see the error message.
If you don't want to post it here, you can send it via email: customer.service [at] appnitro.comMachForm Founder
Posted 11 years ago # -
I didn't see any error messages or warnings - the form just didn't show. If you still want a page to see the code on a live page let me know and I will set it up for you - can give you ftp as well.
Posted 11 years ago # -
Yes please, that would be very helpful. Please contact us directly and let us know the details.
MachForm Founder
Posted 11 years ago # -
Turns out it works with both the SERVER_NAME and the URI. There must have been a problem with the WP site I was testing it on. I have tested the below code and it works just fine.
<script type="text/javascript"> var __machform_url = 'http://xcitemediaforms.com/embed.php?id=59210<?php echo '&element_5='.$_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; ?>'; var __machform_height = 637; </script> <div id="mf_placeholder"></div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/jquery.ba-postmessage.min.js"></script> <script type="text/javascript" src="http://xcitemediaforms.com/js/machform_loader.js"></script>
Thanks for the help.
Posted 11 years ago # -
I'm trying the below method:
`<script type="text/javascript">;
var page_submitted_from = document.referrer;
var __machform_url = "http://xcitemediaforms.com/embed.php?id=92140&element_7="+page_submitted_from;
var __machform_height = 652;
</script>
<div id="mf_placeholder"></div>`And I'm getting the error:
Forbidden
You don't have permission to access /embed.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at xcitemediaforms.com Port 80If I try the below code everything works fine.
<script type="text/javascript"> var page_submitted_from = 'testing'; //using a simple string var __machform_url = "http://xcitemediaforms.com/embed.php?id=92140&element_7="+page_submitted_from; var __machform_height = 652; </script> <div id="mf_placeholder"></div>
I'm trying to access the url of the page the form was submitted from...
The reason I am using js to set the page submitted from is the above code is inside a php return statement:
<?php function my_function() { return ' <script type="text/javascript"> var page_submitted_from = document.referrer; var __machform_url = "http://xcitemediaforms.com/embed.php?id=92140&element_7="+page_submitted_from; var __machform_height = 652; </script> <div id="mf_placeholder"></div> '; }
Thanks ahead of time.
Posted 11 years ago # -
A "404 error" means you have some trouble with the path of your forms.
Are you familiar with Firebug (plugin for Firefox)?Using the Network tool, you can see if your form have the correct path or not.
MachForm Founder
Posted 11 years ago #
Reply
You must log in to post.