<?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: How to add a field that calculates the sum of other fields ?</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: How to add a field that calculates the sum of other fields ?</description>
<language>en</language>
<pubDate>Sun, 03 May 2026 23:30:19 +0000</pubDate>

<item>
<title>daltx7 on "How to add a field that calculates the sum of other fields ?"</title>
<link>https://www.machform.com/forums/topic/how-to-add-a-field-that-calculates-the-sum-of-other-fields-#post-20449</link>
<pubDate>Thu, 13 Mar 2014 23:51:08 +0000</pubDate>
<dc:creator>daltx7</dc:creator>
<guid isPermaLink="false">20449@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Because of the time before the first message, I am trying to find the code in order to insert my own calculation field, but the code no longer exists.  Was there ever a resolution with this or is there a way to do this now?  I can work with the existing script using my own element fields, but need to know where to insert the code and whether it works.  Maybe someone can help with MachForm3.  BTW, Major Release 4.0 and no calculation fields?
&#60;/p&#62;</description>
</item>
<item>
<title>atteam on "How to add a field that calculates the sum of other fields ?"</title>
<link>https://www.machform.com/forums/topic/how-to-add-a-field-that-calculates-the-sum-of-other-fields-#post-14118</link>
<pubDate>Mon, 26 Mar 2012 14:50:58 +0000</pubDate>
<dc:creator>atteam</dc:creator>
<guid isPermaLink="false">14118@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I've tried this but doesn't work.&#60;br /&#62;
No error though...&#60;br /&#62;
can you help?&#60;/p&#62;
&#60;p&#62;thanks a lot
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "How to add a field that calculates the sum of other fields ?"</title>
<link>https://www.machform.com/forums/topic/how-to-add-a-field-that-calculates-the-sum-of-other-fields-#post-6887</link>
<pubDate>Mon, 10 Aug 2009 17:33:01 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">6887@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hmmm .. It's possible to use a javascript for calculation and add a &#34;hidden&#34; field for calculation result. To do so edit &#34;includes/view-functions.php&#34; file and try to follow these steps - It's quite long ;) - :&#60;/p&#62;
&#60;p&#62;1. Go to line 1818 ~ 1822, you will see these code : &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if($has_calendar){
	$calendar_js = &#38;#39;&#38;lt;script type=&#38;quot;text/javascript&#38;quot; src=&#38;quot;js/calendar.js&#38;quot;&#38;gt;&#38;lt;/script&#38;gt;&#38;#39;;
}else{
	$calendar_js = &#38;#39;&#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Put these code exactly bellow that line &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_GET[&#38;#39;id&#38;#39;] == 3) {
$calculate_js = &#38;lt;&#38;lt;&#38;lt;EOT
&#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;

function calculate() {
		//reset text box value

		$(&#38;#39;#element_4&#38;#39;).val(&#38;#39;0&#38;#39;);

		sum_data = parseInt($(&#38;#39;#element_1&#38;#39;).val()) + parseInt($(&#38;#39;#element_2&#38;#39;).val()) + parseInt($(&#38;#39;#element_3&#38;#39;).val()) ;

		$(&#38;#39;#element_4&#38;#39;).val (sum_data);

	}

&#38;lt;/script&#38;gt;
EOT;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;2. Go to line 1851 and you will see this code &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;script type=&#38;quot;text/javascript&#38;quot; src=&#38;quot;js/view.js&#38;quot;&#38;gt;&#38;lt;/script&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;put this code exactly bellow that line &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;script type=&#38;quot;text/javascript&#38;quot; src=&#38;quot;js/jquery/jquery-core.js&#38;quot;&#38;gt;&#38;lt;/script&#38;gt;
{$calculate_js}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;3. Go to around line 40, you'll see 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;put these code above that line &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_GET[&#38;#39;id&#38;#39;] == 3) {
$onchange_script = &#38;#39; onchange=&#38;quot;javascript:calculate();&#38;quot; &#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;4. Go to line 44, you will see 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 to&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;input {$onchange_script} 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;I there I assume your form id = 3 and the text box id to be calculated are 1,2,3, with field result id = 4.&#60;/p&#62;
&#60;p&#62;Anyway for the result, I suggest to use a hidden field instead an admin only field, to hide the result field (element_4), you can add this CSS code to your CSS form : &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#li_4
{
display:none !important;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Make sure you've change those id.
&#60;/p&#62;</description>
</item>
<item>
<title>Leopard on "How to add a field that calculates the sum of other fields ?"</title>
<link>https://www.machform.com/forums/topic/how-to-add-a-field-that-calculates-the-sum-of-other-fields-#post-6883</link>
<pubDate>Sun, 09 Aug 2009 22:57:08 +0000</pubDate>
<dc:creator>Leopard</dc:creator>
<guid isPermaLink="false">6883@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Any idea ?
&#60;/p&#62;</description>
</item>
<item>
<title>Leopard on "How to add a field that calculates the sum of other fields ?"</title>
<link>https://www.machform.com/forums/topic/how-to-add-a-field-that-calculates-the-sum-of-other-fields-#post-6835</link>
<pubDate>Wed, 05 Aug 2009 03:53:12 +0000</pubDate>
<dc:creator>Leopard</dc:creator>
<guid isPermaLink="false">6835@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;i need a field which is visible for admin only this field calculates the sum of other fields:&#60;/p&#62;
&#60;p&#62;element_4 = element_1 + element_2 + element_3 &#60;/p&#62;
&#60;p&#62;the field must be generated automatically and can be changed only if the the other fields changed so the sum will be changed &#60;/p&#62;
&#60;p&#62;Thanks   :)
&#60;/p&#62;</description>
</item>

</channel>
</rss>
