Forums

Chronoforms V6 Calculator

cre8tivemedia 21 Aug, 2018
Am I missing something with the widget calculator settings? I've followed the tutorial in the FAQ's section (Creating a calculation form in Chronoforms6). Added two text fields - field1 and field2 and for some reason can't get the calculator to show the total.






I can see in the inspector that the "total" value is changing when I make a change in the form but the "widget_calculator_value" does not

Am I missing a step?

Thanks,
Matt

Joomla 3.8.11
CFV6
GreyHead 21 Aug, 2018
Hi Matt,

Please try replacing #total with #widget_calculator_value if that is the id of the element you are using to show the result.

Bob
GreyHead 21 Aug, 2018
Hi Matt,

Your 'widget_calculator_value' element is a span, not a hidden input and so doesn't have a 'value'. You need to change the text in the span if you want to use that - or syou could use a readonly input instead.

Bob
cre8tivemedia 21 Aug, 2018
Hi Bob,

Thanks for the help but now I'm more confused than before... Is this a setting in the widget calculator or in javascript or a completely unrelated area that I need an additional field for?
The example that you showed in the FAQs section seemed pretty straight forward, I guess I'm just not versed enough to understand what I'm missing
​I'm basically trying to replicate the calculator that you show in the FAQ section to understand how it works before I build my form and do more complex calculations

Thanks,
Matt
healyhatman 22 Aug, 2018
The element you have ID'd as widget_calculator_value is a <span> - spans don't have a value, you can't use .val()

In your provided code, you should use jQuery("#total").val(blahblahblah)
cre8tivemedia 22 Aug, 2018
Still confused... You're saying I can't use .val() but then want me to use jQuery("#total").val(blahblahblah) - isn't that using .val() or are you saying I can use it for the hidden field "total" but not the "widget_calculator_value" field?


So, here is the latest version of what I put in for the code:
$("#field1,#field2").on("change", function(){
jQuery("#total").val(parseInt($("#field1").val()) + parseInt($("#field2").val()));
});
this is my calculator widget:



this is what I get:



The "total" value is adding up correctly when I change the two fields. I understand that it is a span but I don't understand how to get the "total" value to show where the "widget_calculator_value" is. I believe this field is generated by the chronoforms calculator widget itself from the "Widget ID" correct?

Thank you guys for your help
Matt
healyhatman 22 Aug, 2018
Answer
2 Likes
OK so the way that widget works is under the events tab for the field that holds the value you want to add to the total, you use an add to / subtract from / multiply with action, with the hidden total field as the "Element(s) identifier".

No additional javascript needed, unless you want to use another hidden field to put a custom calculated value into, and have the onchange of that update the total as well.
cre8tivemedia 23 Aug, 2018
Oh ok, now I get it... I had a feeling I was over-complicating things. I will need to use the additional javascript for other fields since more complex calculations for various scenarios will be needed, but now I understand how I can do that. It's been a couple of years since I've used Chronoforms and things have changed quite a bit (in a good way).

Thanks for your help on this

Matt
TWC 14 Jan, 2019
I am searching for a simple solution to calculate prices for different variations of a single product:

I used the demo of dynamic dropdown to create a form:


The dropdown "Lattenquerschnitt" has tree options (every option has a single price)
The dropdown "Lattenfarbe" has no influence on the pricing but is dependend on Lattenquerschnitt (this works perfectly fine).
The dropdown "Lattenlänge" has four options. My problem is that every option of Lattenquerschnitt has a different price in every length (Lattenlänge").
The textfield "Text label" was foreseen to just show the price per unit.

I tried the calculator widget but i do not have a clue where to "store" the prices of every variable!!!

Can you please help!
healyhatman 14 Jan, 2019
1 Likes
You can store the price of every variable as the values of Lattenquerschnitt or whatever. You can build those price values in your reload event
TWC 17 Jan, 2019
Could you please post a short example?
healyhatman 17 Jan, 2019
look at the dynamic dropdown demo.
TWC 23 Jan, 2019
The value of "Lattenfarbe" is built in the reload event, but i need to store 2 values: Lattenquerschnitt and Lattenlaenge.

https://www.c-mueller.biz/index.php?option=com_chronoforms6&chronoform=test
TWC 24 Jan, 2019
I am sorry. I posted a link to the form that you can see and use the form but this was the link to the administration area. Now I corrected the link:

https://www.c-mueller.biz/index.php?option=com_chronoforms6&chronoform=test

Moreover I attached some pictures to explain the way the form is designed.






I do not have a clue where I can store the different prices for different Lattenlaenge and Lattenfarbe!!!
healyhatman 24 Jan, 2019
So you would build it in the reload event. Create an array of key/value pairs based on the option of the first drop down. The dynamic dropdown demo should show you everything you need to get started.
This topic is locked and no more replies can be posted.