Smartform Gold

From rbachwiki
Revision as of 21:07, 8 August 2016 by Bacchas (talk | contribs)
Jump to navigation Jump to search

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

 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; 
} 

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;