<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: Prefill form fields from URL variable pairs</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: Prefill form fields from URL variable pairs</description>
<language>en</language>
<pubDate>Sun, 03 May 2026 21:01:39 +0000</pubDate>

<item>
<title>businessschool on "Prefill form fields from URL variable pairs"</title>
<link>https://www.machform.com/forums/topic/prefill-form-fields-from-url-variable-pairs#post-23913</link>
<pubDate>Wed, 26 Aug 2015 07:37:23 +0000</pubDate>
<dc:creator>businessschool</dc:creator>
<guid isPermaLink="false">23913@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;OK, so found something interestingish, DON'T include the &#38;lt;script type=&#34;text/javascript&#34;&#38;gt; tags in your custom javascript, I have added a couple of alerts to check that the script is loading and it appears to be.. must have errors in my code for it not to work&#60;/p&#62;
&#60;p&#62;function getParameterByName(name)&#60;br /&#62;
{&#60;br /&#62;
  name = name.replace(/[\[]/, &#34;\\\[&#34;).replace(/[\]]/, &#34;\\\]&#34;);&#60;br /&#62;
  var regexS = &#34;[\\?&#38;#38;]&#34; + name + &#34;=([^&#38;amp;#]*)&#34;;&#60;br /&#62;
  var regex = new RegExp(regexS);&#60;br /&#62;
  var results = regex.exec(window.location.search);&#60;br /&#62;
  if(results == null)&#60;br /&#62;
	return &#34;&#34;;&#60;br /&#62;
  else&#60;br /&#62;
    return decodeURIComponent(results[1].replace(/\+/g, &#34; &#34;));&#60;br /&#62;
}&#60;br /&#62;
 // Load all form elements with variable values here&#60;br /&#62;
window.onload = function(){&#60;br /&#62;
    window.alert(&#34;Onload function&#34;) ;&#60;br /&#62;
	$(&#34;#element_3&#34;).val(getParameterByName('first_name'));&#60;br /&#62;
	$(&#34;#element_4&#34;).val(getParameterByName('last_name'));&#60;br /&#62;
}&#60;br /&#62;
window.alert(&#34;In the script&#34;) ;
&#60;/p&#62;</description>
</item>
<item>
<title>businessschool on "Prefill form fields from URL variable pairs"</title>
<link>https://www.machform.com/forums/topic/prefill-form-fields-from-url-variable-pairs#post-23912</link>
<pubDate>Wed, 26 Aug 2015 06:58:39 +0000</pubDate>
<dc:creator>businessschool</dc:creator>
<guid isPermaLink="false">23912@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hey Frankzobitz, thanks for taking the time to reply. &#60;/p&#62;
&#60;p&#62;I need to fill the elements with values that are present in the URL, e.g. if the URL was&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://whatevermysiteis.com/index.php?name=whatever&#38;#38;gender=male&#34; rel=&#34;nofollow&#34;&#62;http://whatevermysiteis.com/index.php?name=whatever&#38;#38;gender=male&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I would like for example to have element_3 have the value of the name variable i.e. whatever and element_4 to have the value of hte gender variable i.e. male&#60;/p&#62;
&#60;p&#62;I am currently trying to implement a custom JS that fires on page load, grabs all the variables from the URL and sets the values of the form elements as defined in the script, not much success so far :=] Any help appreciated, current script is as follows:&#60;/p&#62;
&#60;p&#62;&#38;lt;script type=&#34;text/javascript&#34;&#38;gt;&#60;/p&#62;
&#60;p&#62; function getParameterByName(name)&#60;br /&#62;
{&#60;br /&#62;
  name = name.replace(/[\[]/, &#34;\\\[&#34;).replace(/[\]]/, &#34;\\\]&#34;);&#60;br /&#62;
  var regexS = &#34;[\\?&#38;#38;]&#34; + name + &#34;=([^&#38;amp;#]*)&#34;;&#60;br /&#62;
  var regex = new RegExp(regexS);&#60;br /&#62;
  var results = regex.exec(window.location.search);&#60;br /&#62;
  if(results == null)&#60;br /&#62;
    return &#34;&#34;;&#60;br /&#62;
  else&#60;br /&#62;
    return decodeURIComponent(results[1].replace(/\+/g, &#34; &#34;));&#60;br /&#62;
}&#60;br /&#62;
 // Load all form elements with variable values here&#60;br /&#62;
window.onLoad = function(){&#60;br /&#62;
    $(&#34;#element_5&#34;).val(getParameterByName('last_name'));&#60;br /&#62;
}&#60;br /&#62;
 &#38;lt;/script&#38;gt;&#60;/p&#62;
&#60;p&#62;Cheers
&#60;/p&#62;</description>
</item>
<item>
<title>frankzobitz on "Prefill form fields from URL variable pairs"</title>
<link>https://www.machform.com/forums/topic/prefill-form-fields-from-url-variable-pairs#post-23859</link>
<pubDate>Fri, 14 Aug 2015 09:48:17 +0000</pubDate>
<dc:creator>frankzobitz</dc:creator>
<guid isPermaLink="false">23859@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Are you modifying the URL of the code within the javascript?&#60;/p&#62;
&#60;p&#62;The second line of the javascript code is something like this: (I just took from the demo site)&#60;br /&#62;
var __machform_url = 'http://www.appnitro.com/demo/embed.php?id=6';&#60;/p&#62;
&#60;p&#62;That is where you want to append your: &#38;#38;element_5=Whatever&#38;#38;element_6=Whatelse&#60;br /&#62;
so this would be the code you would paste onto your website:&#60;/p&#62;
&#60;p&#62;&#38;lt;script type=&#34;text/javascript&#34;&#38;gt;&#60;br /&#62;
var __machform_url = 'http://www.appnitro.com/demo/embed.php?id=6&#38;#38;element_5=Whatever&#38;#38;element_6=Whatelse';&#60;br /&#62;
var __machform_height = 627;&#60;br /&#62;
&#38;lt;/script&#38;gt;&#60;br /&#62;
&#38;lt;div id=&#34;mf_placeholder&#34;&#38;gt;&#38;lt;/div&#38;gt;&#60;br /&#62;
&#38;lt;script type=&#34;text/javascript&#34; src=&#34;http://www.appnitro.com/demo/js/jquery.min.js&#34;&#38;gt;&#38;lt;/script&#38;gt;&#60;br /&#62;
&#38;lt;script type=&#34;text/javascript&#34; src=&#34;http://www.appnitro.com/demo/js/jquery.ba-postmessage.min.js&#34;&#38;gt;&#38;lt;/script&#38;gt;&#60;br /&#62;
&#38;lt;script type=&#34;text/javascript&#34; src=&#34;http://www.appnitro.com/demo/js/machform_loader.js&#34;&#38;gt;&#38;lt;/script&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>businessschool on "Prefill form fields from URL variable pairs"</title>
<link>https://www.machform.com/forums/topic/prefill-form-fields-from-url-variable-pairs#post-23857</link>
<pubDate>Fri, 14 Aug 2015 07:59:16 +0000</pubDate>
<dc:creator>businessschool</dc:creator>
<guid isPermaLink="false">23857@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hey Saghalie, thanks for getting back to me... can't find a setting on this forum to notify me when replies are posted :=]. &#60;/p&#62;
&#60;p&#62;I am using the Javascript embed method...&#60;/p&#62;
&#60;p&#62;I am loading my URL with variables that are parsed from contact records in my CRM. I have tried manually loading the variables in the URL, doesn't work in a form that is embedded in a Drupal site, does work in the View option from the MachForm interface e.g. this works from the View menu&#60;/p&#62;
&#60;p&#62;[mywebsiteURL]/view.php?id=14337&#38;#38;element_5=Whatever&#60;/p&#62;
&#60;p&#62;This DOES NOT work in my drupal site with an embedded form&#60;/p&#62;
&#60;p&#62;[mywebsiteURLwithformembedded]?element_5=Whatever&#38;#38;element_6=Whatelse&#60;/p&#62;
&#60;p&#62;I have checked the names of the form fields and they are as above, element_[n]&#60;/p&#62;
&#60;p&#62;Thanks for any assistance you can give me&#60;/p&#62;
&#60;p&#62;Marty
&#60;/p&#62;</description>
</item>
<item>
<title>Saghalie on "Prefill form fields from URL variable pairs"</title>
<link>https://www.machform.com/forums/topic/prefill-form-fields-from-url-variable-pairs#post-23789</link>
<pubDate>Fri, 07 Aug 2015 11:37:43 +0000</pubDate>
<dc:creator>Saghalie</dc:creator>
<guid isPermaLink="false">23789@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;What embed method are you using?&#60;/p&#62;
&#60;p&#62;Saghalie&#60;br /&#62;
&#60;a href=&#34;http://www.kcmhosting.com&#34; rel=&#34;nofollow&#34;&#62;http://www.kcmhosting.com&#60;/a&#62;
&#60;/p&#62;</description>
</item>
<item>
<title>businessschool on "Prefill form fields from URL variable pairs"</title>
<link>https://www.machform.com/forums/topic/prefill-form-fields-from-url-variable-pairs#post-23781</link>
<pubDate>Thu, 06 Aug 2015 16:21:53 +0000</pubDate>
<dc:creator>businessschool</dc:creator>
<guid isPermaLink="false">23781@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I'm having problems preloading my machform fields with data passed in via the URL. My form is included using the Javascript code into a Drupal website/page. The preloading works when I do it via the View function in the MachForm builder and load the URL with variable pairs, BUT as soon as I embed the form in my Drupal site, the preload fails. This is a very important function for our business, has anyone had any problems with this functionality before? Does the URL have to reference the form id when it is embedded in a webpage?&#60;/p&#62;
&#60;p&#62;I have tried the following to no avail&#60;/p&#62;
&#60;p&#62;[myformURL]?element1=testing&#38;#38;element2=testingagain&#60;br /&#62;
[myformURL]?form_id=13941&#38;#38;element1=testing&#38;#38;element2=testingagain&#60;br /&#62;
[myformURL]?formid=13941&#38;#38;element1=testing&#38;#38;element2=testingagain&#60;/p&#62;
&#60;p&#62;Any thoughts/assistance greatly appreciated
&#60;/p&#62;</description>
</item>

</channel>
</rss>
