Forums

AutoSum - calculation

dheio 10 Aug, 2015
Good morning
I would like to ask if it was possible to make an automatic calculation.
That is, I would use the form within a reservation, and then wonder if it is possible to calculate the total cost of the stay, by calculating the total number of nights of accommodation.
The total number of nights I could do using "DataPicker Box" (Or other)

Thanks
GreyHead 10 Aug, 2015
Hi dheio,

You can use Custom JavaScript in the form On Load event (and/or custom PHP in the On Submit event). Or you could use a date-picker just for the start dates, let the user specify the length and calculate the end date.

Bob
dheio 10 Aug, 2015
Hi Bob ,
thank's for your reply.
So If I have the number of night, Can I calculate the total price?
Example: 3 night * € 50 = Total € 150
Thank's
GreyHead 10 Aug, 2015
Hi dheio,

Yes you can - as I said, you'll need to write a few lines of custom code to do that.

Bob
dheio 09 Sep, 2015
Hi Bob,
and thank's for your reply..
I'm ashamed to say it, but I can not find "Custom JavaScript in the form On Load event"
I read here https://www.chronoengine.com/faqs/54-cfv4/cfv4-validation/2597-how-can-i-add-javascript-to-my-form.html, but nothing.. where is th Load Event?
Thanks
GreyHead 09 Sep, 2015
Hi dheio,

If you are using the Simple Wizard then there is a JavaScript tab you can see when you click the Setup button.

Bob
dheio 10 Sep, 2015
Hi Bob
thank's for you reply,
so can I write in php in Javascript tab?
Thanks
GreyHead 11 Sep, 2015
Hi dheio,

Well, yes you can - as long as the result is valid JavaScript.

Bob
dheio 11 Nov, 2015
Hi Bob,
sorry for my delay..
unfortunately I'm not very good with the Javascript code.
I tried to make this code but nothing happens
var arrivo={dataarrivo};
var partenza= {datapartenza};

totgiorni=dataarrivo - datapartenza ;

console.log(togiorni);
GreyHead 11 Nov, 2015
Hi dheio,

This isn't JavaScript var arrivo={dataarrivo}; - there are many many examples in the forums here.

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