Difference between revisions of "Smartform Gold"

From rbachwiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 35: Line 35:
After that you will have a capability to insert a value of "total" in your email template through the simple dynamic variable.
After that you will have a capability to insert a value of "total" in your email template through the simple dynamic variable.
</pre>
</pre>
==Subtotal fields - Smart Form ==
<pre>
Let's say our form has 2 input boxes, which have IDs 'field1' and 'field2'.
There is also a Static Text element (ID='total') where the sum should be displayed.
We will need to open JavaScript editor from the top menu. To the end of the code let us add the following:
function outputTotal() {
var sum = 0;
var fields = Array('field2', 'field3','field4','field5','field6','field7','field8','field9','field10','field11','field12','field13','field14','field15','field16','field17','field18','field19');
for (i=0; i<fields.length; i++) {
field = document.getElementById(fields[i]);
if (field) sum += field.value-0;
}
document.getElementById('total').innerHTML = +sum;
}
Then click the first input box. In its properties there is Events tab. In it there is "onblur" event. Please add the following to this even of both input boxes:
Code:
outputTotal()
The form can be found at: http://www.myjennco.com/index.php?option=com_sfg&Itemid=59
</pre>
==Print a form before submitting ==
<pre>
Add a button to the form
on click action -> run custom js line
add line below
window.print();return false;
</pre>
[[#Smart Form - Another way to subtotal fields| Back to Top]]

Latest revision as of 12:55, 9 August 2016

Smart Form - Another way to subtotal fields

1.Insert on the page one more field (input, text). 2.Define an id for it: "total". 
3.Define a name for it: "total". 
4.Open it's MSDN properties->Styles->display. 
5.Open a PHP editor for this style and enter: 

Code:
echo "hidden";

6.Insert the static text (<span> element) on the page. 
7.Define an id for it: "total_span". 
8.Define IDs for your text boxes (e.g. "textbox1", "textbox2", "textbox3"). 
9.Add this JS-code in "onchange" event of every text box: 

Code:
calculate();

10.Open JS ditor and add at the end the following: 

Code:
function calculate(){ 
 var value1 = document.getElementById('textbox1').value; 
 var value2 = document.getElementById('textbox2').value; 
 var value3 = document.getElementById('textbox3').value; 
 if (value1 == '') value1 = '0'; 
 if (value2 == '') value2 = '0'; 
 if (value3 == '') value3 = '0'; 
 var total = parseInt(value1) +parseInt(value2) +parseInt(value3); 
 document.getElementById('total_span').innerHTML=''+total; 
 document.getElementById('total').value=''+total; 
}


After that you will have a capability to insert a value of "total" in your email template through the simple dynamic variable.

Subtotal fields - Smart Form

Let's say our form has 2 input boxes, which have IDs 'field1' and 'field2'. 
There is also a Static Text element (ID='total') where the sum should be displayed. 
We will need to open JavaScript editor from the top menu. To the end of the code let us add the following:


 function outputTotal() { 
var sum = 0; 
var fields = Array('field2', 'field3','field4','field5','field6','field7','field8','field9','field10','field11','field12','field13','field14','field15','field16','field17','field18','field19');
for (i=0; i<fields.length; i++) { 
field = document.getElementById(fields[i]); 
if (field) sum += field.value-0; 
} 
document.getElementById('total').innerHTML = +sum; 
} 

Then click the first input box. In its properties there is Events tab. In it there is "onblur" event. Please add the following to this even of both input boxes: 

Code:
outputTotal()

The form can be found at: http://www.myjennco.com/index.php?option=com_sfg&Itemid=59 

Print a form before submitting

Add a button to the form
on click action -> run custom js line
add line below
window.print();return false;

Back to Top