Hi,
I just created an easy form which you can see here:
http://www.hjirenno.nl/index.php?option=com_chronoforms&chronoform=kaartenbestelle24maaie
Visitors can order cards for an event (in the field "Oantal Kaarten")
In the email I just want to calculate the total price, based on the number which is entered by the user like this 7,50*Oantal Kaarten.
This is what I already tried, but it doesn't work
<?php $oantal=&form->data['oantal'] echo 7,50*$oantal;?>
Thanks in advance
I just created an easy form which you can see here:
http://www.hjirenno.nl/index.php?option=com_chronoforms&chronoform=kaartenbestelle24maaie
Visitors can order cards for an event (in the field "Oantal Kaarten")
In the email I just want to calculate the total price, based on the number which is entered by the user like this 7,50*Oantal Kaarten.
This is what I already tried, but it doesn't work
<?php $oantal=&form->data['oantal'] echo 7,50*$oantal;?>
Thanks in advance
Hello!
It seems to me that there is an error in your code:
should be
Then, are you sure that $form->data['oantal'] is a number or a numeric value, because if it is a text, this couldn't work.
Flo
It seems to me that there is an error in your code:
<?php $oantal=&form->data['oantal'] echo 7,50*$oantal;?>should be
<?php $oantal=$form->data['oantal'] echo 7,50*$oantal;?>Then, are you sure that $form->data['oantal'] is a number or a numeric value, because if it is a text, this couldn't work.
Flo
Hi Flob,
Thanks for your quick reply,
I get a blank email with the adjusted code
(yes, The field "oantal" is a number.)
Any other suggestions would be welcome.
Kind Regards,
Liesbeth
Thanks for your quick reply,
I get a blank email with the adjusted code
(yes, The field "oantal" is a number.)
Any other suggestions would be welcome.
Kind Regards,
Liesbeth
Hi!
Try adding a ";" before the echo and change the "," by a ".":
Flo
Try adding a ";" before the echo and change the "," by a ".":
<?php $oantal=$form->data['oantal']; echo 7.50*$oantal;?>Flo
Thank you very much, it works just fine!
Do you have a hint how I can change the "." into a "," so the output will be (for example) 30,00 euro instead of 30.00 euro?
Do you have a hint how I can change the "." into a "," so the output will be (for example) 30,00 euro instead of 30.00 euro?
The following code permits to set the number of decimals, the decimal separator and the thousand separator : string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
You can use it like this:
to have 2 decimals after a "," and thousands separated by a " ".
If you start using php, I have found this web site no long ago (newbe myself).
Good luck
Flo
You can use it like this:
<?php $oantal=$form->data['oantal']; echo number_format(7.50*$oantal, 2, ',', ' ');?>to have 2 decimals after a "," and thousands separated by a " ".
If you start using php, I have found this web site no long ago (newbe myself).
Good luck
Flo
This topic is locked and no more replies can be posted.
