Realtime Form Calculation

johnvalera 12 Oct, 2012
I'm new to Chronoforms. I'm having difficulties wrapping my head around the concept vs hard coding the form. I'm write the code that adds the multiple fields and outputs results in a text field below in realtime. Can someone give me examples on what the syntax would look like.

Example
[field1]
[field2]
[field3]
Total: [total]

This is the most successful line the problem is that it won't give me the total in realtime. What am I doing wrong?

<?PHP

$totalacq = $_POST['down_payment'] + $_POST['purch_closing'] + $_POST['appraisal'] + $_POST['survey'] + $_POST['prop_inspection'] + $_POST['termite'] + $_POST['finders_commission'] + $_POST['acq_misc'] ;

echo $totalacq;

?>
GreyHead 12 Oct, 2012
Hi johnvalera,

I'm not clear what you want to do here??

If you want to do real-time calculation in the browser then you will need to use JavaScript. (There are some examples in the forums here.)

PHP only runs on the server and therefore can only be used before the form is loaded - when there are no results to add up; or after the form is submitted.

Bob
This topic is locked and no more replies can be posted.