This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 3
Need to set State to default of North Carolina
Started 12 years ago by kevbarker | 8 posts |
-
I would like to set the State field to a default of North Carolina. How can I do that? I am using MachForm version 3.3.
Posted 12 years ago # -
I also have this request in, but for a different state. How does one do this?
Posted 12 years ago # -
Hi,
We afraid, currently you unable to set default value of the state directly on machform admin page.
The easy way, you can put the value into your form url variable. For example, if you have address field with element id 2, you can put the url variable like this :http://yourdomain.colm/machform/view.php?id=10914&element_2_4=North%20Carolina
You need to change the id's with yours
MachForm Support
Posted 12 years ago # -
Thanks. I have that working when using Javascript. I prefer using the PHP embed method sometimes...
What would I need to do for PHP Embed code?
Here is a sample of the embed code. Is there a parameter I can pass here to set the state to default to North Carolina?
<?php
require("/home/xxxx/yyyy.com/forms/machform.php");
$mf_param['form_id'] = 10574;
$mf_param['base_path'] = 'http://yyyy.com/forms/';
display_machform($mf_param);
?>Thanks again for your great support!
Kevin
Posted 12 years ago # -
Any recommendations on passing the value when using PHP embed code?
Posted 12 years ago # -
If you are using the PHP embed code, this pretty much depends on any other PHP codes on that page. If the PHP codes doesn't alter any $_GET request, then the method is pretty much the same.
Let say you have a page named "form.php" and the form is being embedded there.
You can use something like this:
http://www.example.com/form.php?element_2_4=North%20Carolina
The problem is, if you are using CMS such as WordPress or Joomla, the above won't work, because the parameters most likely has been altered by the CMS.
MachForm Founder
Posted 12 years ago # -
Yuniar,
Thanks for the reply. In this case I am not working with a CMS or other PHP code in the page. Only the form code and HTML. I think what you show would work if I was linking directly to a page with the form, but I want to embed the form with the PHP embed code.
I may not have explained what I was trying to do very well. If I use the Javascript method of inserting the form into an existing page I would go to Form Manager->Code-> then Select Javascript Code which would give me this:
<script type="text/javascript">
var __machform_url = 'http://xxxx.com/forms/embed.php?id=10574';
var __machform_height = 1102;
</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://xxxx.com/forms/js/jquery.ba-postmessage.min.js"></script>
<script type="text/javascript" src="http://xxxx.com/forms/js/machform_loader.js"></script>...and I could modify the following line in the above section of code...
from this:
var __machform_url = 'http://xxxx.com/forms/embed.php?id=10574';
to this:
var __machform_url = 'http://xxxx.com/forms/embed.php?id=10574&element_2_4=North%20Carolina'';and it works great.
However I would like to go to Form Manager->Code-> then Select PHP Embed Code. Which gives me the following code:
<?php
require("/home/xxx/yyy.com/forms/machform.php");
$mf_param['form_id'] = 10574;
$mf_param['base_path'] = 'http://xxx.com/forms/';
display_machform($mf_param);
?>Where in the above code that MachForm gives me for PHP embed would I add the: &element_2_4=North%20Carolina to make it work?
I tried appending it to $mf_param['form_id'] = 10574; like this: $mf_param['form_id'] = 10574&element_2_4=North%20Carolina; but that failed (blank page).
Sorry to keep bothering you and if I am being a total dummy and missing something.
Thanks again,
KevinPosted 12 years ago # -
ah.. I see. You can do it like this:
<?php require("/home/xxx/yyy.com/forms/machform.php"); $mf_param['form_id'] = 10574; $mf_param['base_path'] = 'http://xxx.com/forms/'; $_GET['element_2_4'] = 'North Carolina'; display_machform($mf_param); ?>
MachForm Founder
Posted 12 years ago #
Reply
You must log in to post.