This is a great component and one of the best for Joom. I will start off by saying my php level is basic and trying to scratch the surface of intermediate (depending on the day: ). Anyways I am struggling on the following issue and it’s more a php question then a Chrono one.
I have a checklist that has a number of basic input fields and after submitted, it emails to a specific group.
I want to take this field’s entry:
<input name="amps" type="text" size="5" />
and multiply it to get the total watts -Of course its not as easy as I thought, this doesn’t work nor did I expect it to be that easy:
<input type="hidden" name="watts" value="<?php echo amps * 8; ?>" />
amps produces 0 so the email shows a 0. I can experiment and define $amps as a # and then echo $amps * 8 and I get the right results. I have tried a slough of different options to define amps differently and my head hurts now so time to ask for some assistance🙂
Any help or pointers in the right direction would be much appreciated.
Bryan
I have a checklist that has a number of basic input fields and after submitted, it emails to a specific group.
I want to take this field’s entry:
<input name="amps" type="text" size="5" />
and multiply it to get the total watts -Of course its not as easy as I thought, this doesn’t work nor did I expect it to be that easy:
<input type="hidden" name="watts" value="<?php echo amps * 8; ?>" />
amps produces 0 so the email shows a 0. I can experiment and define $amps as a # and then echo $amps * 8 and I get the right results. I have tried a slough of different options to define amps differently and my head hurts now so time to ask for some assistance🙂
Any help or pointers in the right direction would be much appreciated.
Bryan
Hi Bryan,
As you've found 'amps' doesn't have a value until the form is submitted so you can't do this through an input field.
You can do it in the output though. If you are using an html template then try something like
Bob
As you've found 'amps' doesn't have a value until the form is submitted so you can't do this through an input field.
You can do it in the output though. If you are using an html template then try something like
You input
<?php echo $_POST['amps'] ?>
this means that the power will be
<?php echo $_POST['amps']*8 ?>watts.
Bob
Hi Bryan,
If you will use PHP then please follow Bob's solution, however to achieve what u need u have to use javascript, put this code at the HTML box :
and this on the javascript box :
Voila, u r done B)
Cheers
Max<br><br>Post edited by: admin, at: 2007/06/11 12:53
If you will use PHP then please follow Bob's solution, however to achieve what u need u have to use javascript, put this code at the HTML box :
<input name="amps" id="amps" onChange="calcwatts()" type="text" size="5" />
<input type="hidden" name="watts" id="watts" value="" />
and this on the javascript box :
function calcwatts(){
document.getElementById('watts').value = document.getElementById('amps').value * 8;
}
Voila, u r done B)
Cheers
Max<br><br>Post edited by: admin, at: 2007/06/11 12:53
Thank you for the quick responses🙂
I will give those a whirl and report back.
I will give those a whirl and report back.
Thanks Bryan, Thanks Bob!!!
I can't seem to get this to work as my email value still says 0 (zero) even though it appreas to be working fine on my form.
My HTML:
sub_total is calculated based on the value of the drop down noguests. (ie if noguests=1 then sub_total=1*150)
Javascript:
Email Template:
Any ideas?
Thank you
My HTML:
<input name="sub_total" type="text" id="sub_total" value="$0.00" size="10" maxlength="10" onFocus="this.form.elements[0].focus()">
<input name="sub_total2" id="sub_total2" value="" type="hidden">
sub_total is calculated based on the value of the drop down noguests. (ie if noguests=1 then sub_total=1*150)
Javascript:
var subtotal=document.ChronoContact_Legacy.sub_total.value; document.ChronoContact_Legacy.sub_total2.value=subtotal;
//test to see if sub_total2 value is correct
//alert(document.ChronoContact_Legacy.sub_total2.value);
Email Template:
<div align="left"><strong>SUB TOTAL: </strong>
{sub_total2} paid by {card_type} </div>
Any ideas?
Thank you
Try to simplify the code and don't use onFocus...etc and don't use an email template, try to start from the same code as above then track the problem!!
Cheers
Max
Cheers
Max
Ok, I've been doing this and here is something interesting.
If the total is $300 it sends 0 (via email template)
If the total is $1200 is sends 00
If the total is $11800 it send 800
So obviously the first three characters are not being sent.
Again it is appearing in the db correctly and also on the "summary form" after the onsubmit.
What could cause something like this?
Anyone interesting in helping me please, can take a look at:
If the total is $300 it sends 0 (via email template)
If the total is $1200 is sends 00
If the total is $11800 it send 800
So obviously the first three characters are not being sent.
Again it is appearing in the db correctly and also on the "summary form" after the onsubmit.
What could cause something like this?
Anyone interesting in helping me please, can take a look at:
http://rmcclubfoundation.ca/joomla/index.php?option=com_chronocontact&chronoformname=Legacy&Itemid=27
<br><br>Post edited by: kstlouis, at: 2007/06/15 16:49
Hmmmmm, strange, the initial value you have is value="$0.00" , do you take care when you add or multiply that there is a $ which may make the calculations wrong ? although all results should be 00 this way!!
Max
Max
Yes, I was thinking about this. I'm going to try removing the "$" and see what happens.
Thanks for you help and also this great product.
This will save me so much time!
Thanks for you help and also this great product.
This will save me so much time!
This was an awesome post - saved my day. Thanks Max. Just the answer I was looking for.
Great!!🙂
This topic is locked and no more replies can be posted.