<?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: Add custom javascript to form</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: Add custom javascript to form</description>
<language>en</language>
<pubDate>Thu, 21 May 2026 23:31:04 +0000</pubDate>

<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9599</link>
<pubDate>Sat, 29 May 2010 22:17:30 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9599@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;just sent file today.  Thanks.
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9581</link>
<pubDate>Thu, 27 May 2010 17:52:44 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">9581@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Can you send us your file please? and let us know the URL to the form.&#60;br /&#62;
We'll check it.&#60;/p&#62;
&#60;p&#62;Mail to: customer.service [at] appnitro.com
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9573</link>
<pubDate>Wed, 26 May 2010 19:04:32 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9573@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;no workie...  i did make one little change to see if that might be it, but no dice..&#60;/p&#62;
&#60;p&#62;i changed $_SESSION['form_id'] == 5;&#60;br /&#62;
to $_SESSION['form_id'] = 5;&#60;/p&#62;
&#60;p&#62;still not working.  any ideas??&#60;/p&#62;
&#60;p&#62;Thanks so much for the GREAT support!
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9571</link>
<pubDate>Wed, 26 May 2010 15:32:15 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">9571@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;If you're using advance code, you should add the java scipt code around line 2172. You can put exactly above this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;{$calendar_js}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;It's inside &#34;display_integrated_form&#34; function block. And to get the form id with advance embed code, you should use a SESSION variable. You can add like this in advance embed code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php
        @session_start();
	require(&#38;quot;/domain/machform.php&#38;quot;);
	$mf_param[&#38;#39;form_id&#38;#39;] = 1;
        $_SESSION[&#38;#39;form_id&#38;#39;] = 1;
	$mf_param[&#38;#39;base_path&#38;#39;] = &#38;#39;http://domain.com/machform/&#38;#39;;
	display_machform($mf_param);
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;then you can use the session like this &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_SESSION[&#38;#39;form_id&#38;#39;] == 5 &#38;#38;&#38;#38; $element-&#38;gt;id ==  2) {
	$javascript_code = &#38;quot;onblur=\&#38;quot;showLocation(); return false;\&#38;quot;&#38;quot;;
}&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9570</link>
<pubDate>Wed, 26 May 2010 11:59:57 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9570@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;ok, all i need to know now is how to get my if statement to filter on form id.  i can get element-&#38;gt;id to work, but with advanced embed form code, form-&#38;gt;id doesn't seem to work.  can you tell me the variable that is used for form id on advanced embeded form?&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9567</link>
<pubDate>Wed, 26 May 2010 04:08:13 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9567@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;OK.  i seem to have everything working fine if i call the form via url.  but if i embed the form with the advanced form code, my javascripts stop working.  do i need to have the code somewhere else for advanced code placement?
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9535</link>
<pubDate>Sun, 23 May 2010 00:06:29 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9535@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;ok. another thing.  everything seems to work fine calling the form from a url, but if i embed the form in my php template, it doesn't work.
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9527</link>
<pubDate>Sat, 22 May 2010 09:04:46 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9527@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;That worked.  However, i'm getting an error.  my code works and it does exactly what i want it to.  here is the error i'm getting:&#60;/p&#62;
&#60;p&#62;Webpage error details&#60;/p&#62;
&#60;p&#62;User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)&#60;br /&#62;
Timestamp: Sat, 22 May 2010 02:03:09 UTC&#60;/p&#62;
&#60;p&#62;Message: Object doesn't support this property or method&#60;br /&#62;
Line: 1&#60;br /&#62;
Char: 1&#60;br /&#62;
Code: 0&#60;br /&#62;
URI: &#60;a href=&#34;http://url/machform/js/view.js&#34; rel=&#34;nofollow&#34;&#62;http://url/machform/js/view.js&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;here is the javascript code i'm using:&#60;/p&#62;
&#60;p&#62;&#38;lt;script type=&#34;text/javascript&#34;&#38;gt;&#60;br /&#62;
var geocoder;&#60;br /&#62;
var location2;&#60;br /&#62;
var gDir;&#60;/p&#62;
&#60;p&#62;	function initialize() {&#60;br /&#62;
		geocoder = new GClientGeocoder();&#60;br /&#62;
		gDir = new GDirections();&#60;br /&#62;
		GEvent.addListener(gDir, &#34;load&#34;, function() {&#60;br /&#62;
			var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;&#60;br /&#62;
			var drivingDistanceKilometers = gDir.getDistance().meters / 1000;&#60;br /&#62;
			document.form_1.element_6.value = drivingDistanceMiles.toFixed(1);&#60;br /&#62;
			});&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	function showLocation() {&#60;br /&#62;
		geocoder.getLocations(&#34;3120 Alford Bend Rd, Gadsden, AL, 35903&#34;, function (response) {&#60;br /&#62;
			if (!response &#124;&#124; response.Status.code != 200)&#60;br /&#62;
			{&#60;br /&#62;
				alert(&#34;Sorry, we were unable to geocode the first address&#34;);&#60;br /&#62;
			}&#60;br /&#62;
			else&#60;br /&#62;
			{&#60;br /&#62;
				location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};&#60;br /&#62;
				geocoder.getLocations(document.form_1.element_3_1.value + ', ' + document.form_1.element_3_5.value, function (response) {&#60;br /&#62;
					if (!response &#124;&#124; response.Status.code != 200)&#60;br /&#62;
					{&#60;br /&#62;
						alert(&#34;Sorry, we were unable to geocode the second address&#34;);&#60;br /&#62;
					}&#60;br /&#62;
					else&#60;br /&#62;
					{&#60;br /&#62;
						location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};&#60;br /&#62;
						gDir.load('from: ' + location1.address + ' to: ' + location2.address);&#60;br /&#62;
					}&#60;br /&#62;
				});&#60;br /&#62;
			}&#60;br /&#62;
		});&#60;br /&#62;
	}&#60;br /&#62;
&#38;lt;/script&#38;gt;    &#60;/p&#62;
&#60;p&#62;I also added an onload=&#34;initialize();&#34; to the body tag.&#60;/p&#62;
&#60;p&#62;so far i haven't seen any functionality lost, but i'm sure something is missing.&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9521</link>
<pubDate>Fri, 21 May 2010 23:01:14 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9521@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I will give that a try.&#60;/p&#62;
&#60;p&#62;Thanks!!
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9518</link>
<pubDate>Fri, 21 May 2010 14:10:47 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">9518@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Basically you can put the java script in &#34;view-functions.php&#34; file around line 1839, put the script bellow this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;{$calendar_js}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and for example you want to call the java script code on onblur event for text field with element id 2 on form 5. Then, go to 40 for this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$element_markup = &#38;lt;&#38;lt;&#38;lt;EOT&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and add this code above that line &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_GET[&#38;#39;id&#38;#39;] == 5 &#38;#38;&#38;#38; $element-&#38;gt;id ==  2) {
	$javascript_code = &#38;quot;onblur=\&#38;quot;showLocation(); return false;\&#38;quot;&#38;quot;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;after that, go to line around line 46 for this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;input id=&#38;quot;element_{$element-&#38;gt;id}&#38;quot; name=&#38;quot;element_{$element-&#38;gt;id}&#38;quot; class=&#38;quot;element text {$element-&#38;gt;size}&#38;quot; type=&#38;quot;text&#38;quot; value=&#38;quot;{$element-&#38;gt;default_value}&#38;quot; /&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;change it to&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;input id=&#38;quot;element_{$element-&#38;gt;id}&#38;quot; name=&#38;quot;element_{$element-&#38;gt;id}&#38;quot; class=&#38;quot;element text {$element-&#38;gt;size}&#38;quot; type=&#38;quot;text&#38;quot; value=&#38;quot;{$element-&#38;gt;default_value}&#38;quot; {$javascript_code} /&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9517</link>
<pubDate>Fri, 21 May 2010 01:15:18 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9517@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Here is kind of what i want to do:&#60;br /&#62;
&#38;lt;input type=&#34;text&#34; name=&#34;address1&#34; value=&#34;Address 1&#34; onblur=&#34;showLocation(); return false;&#34;/&#38;gt;&#60;/p&#62;
&#60;p&#62;I would also like to have a hidden field that the mileage is written too.
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9516</link>
<pubDate>Fri, 21 May 2010 00:42:25 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9516@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Can you give me some direction on where exactly to put the onblur code?  &#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9515</link>
<pubDate>Thu, 20 May 2010 20:51:46 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9515@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Yes, i would like to add an onblur to the zip code field to calculate the distance from my location to the address entered with a google API.  i would also be interested in adding a button to calculate and display a price for based on some options that were selected on the form.
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9514</link>
<pubDate>Thu, 20 May 2010 20:03:44 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">9514@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;You should edit &#34;view-functions.php&#34; file to add custom java script. May i know what java script code do you want to add ?
&#60;/p&#62;</description>
</item>
<item>
<title>moonlightss on "Add custom javascript to form"</title>
<link>https://www.machform.com/forums/topic/add-custom-javascript-to-form#post-9513</link>
<pubDate>Thu, 20 May 2010 08:42:49 +0000</pubDate>
<dc:creator>moonlightss</dc:creator>
<guid isPermaLink="false">9513@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I would like to add some custom javascript functions to a couple of the fields.  How and where can i do this?&#60;/p&#62;
&#60;p&#62;Thanks
&#60;/p&#62;</description>
</item>

</channel>
</rss>
