Forums

Form calculates amount to be paid

Repitol 04 Mar, 2015
Hi,
this is about the locked thread https://www.chronoengine.com/forums/posts/f2/t88458/is-it-possible-to-chronoforms-to-add-values-from-fields.html
so I open a new topic.
After I added an Event switcher I notice that total field has to be clicked to show the good result
if not it displays the total value except the last amount edited
eg : if values are 2 / 3 / 1 / 4 / 6
total displays the value for 2 + 3 + 1 + 4 (10)
if user clicks on the field "total" it calculates finally 2 + 3 + 1 + 4 + 6 and displays 16
what could be the problem with the code please ?
window.addEvent('domready', function() {
$('total_soiree_restaurant').addEvent('change', rekenen1);
$('total_club').addEvent('change', rekenen1);
  $('total_coupe').addEvent('change', rekenen1);
   $('total_ski_seul').addEvent('change', rekenen1);
    $('total_buffet').addEvent('change', rekenen1);
     $('total_soiree_montagne').addEvent('change', rekenen1);
      $('total_ski_libre').addEvent('change', rekenen1);
});
function rekenen1(){
 $('total_a_payer').value = parseInt($('total_soiree_restaurant').value * 40)+ parseInt($('total_club').value * 15) + parseInt($('total_coupe').value * 30) + parseInt($('total_ski_seul').value * 22) + parseInt($('total_buffet').value * 25) + parseInt($('total_soiree_montagne').value * 60) + parseInt($('total_ski_libre').value * 22)}
GreyHead 04 Mar, 2015
Hi Repitol,

Try changing the code to use 'keyup' instead of 'change'.

Bob
Repitol 04 Mar, 2015
Ok fine, I'll try
the website owner wants to apply a 4% majoration in case of Paypal payment
I think it has to be configurated in the Event switcher code
could you please tell me what to add ?
Repitol 06 Mar, 2015
That's ok with keyup, thanks Bob you're the King !
for my 4% majoration, I will create a new "total" field called 'total_paypal"
and edit the Load JS Action to display the corresponding amount
then, my event switcher will be corrected to use 'total_paypal' when user chooses to pay with Paypal
I think that's the simpliest way according to my competencies.

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