Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Option List in Code (Payment calculator) 15.07.2014 14:05

hello,

I am trying to build a payment calculator. The drop down list determines the length and the interest rate is a text box. I can get it to calculate properly for the first item in the dropdown but when something else is selected the length stays the same.

I use an if/elseif statement to the calculation and it appears that when the calculate button is pressed a second time, the coding does not assign which dropdown item is selected.

Hope this makes sense and that someone can offer me some insight.

Re: Option List in Code (Payment calculator) 15.07.2014 16:36

Hello,
we suggest to double check the values of the options you have set for the combobox. If you have for example a field called 'terms', with these set of pairs (name-value)

Name Value
1 year 1
2 years 2
3 years 3

..you shouldn't need to use if/else conditions:

$result=$terms*10;


Will set result=10 if first value is selected, 20 if second....etc

Hope this helps, if you can't get it working, add a ticket at the helpdesk pasting the code which doesn't calculate the result and we'll take a look looking for any sintax error.

Regards
Moonsoft Team
www.moonsoft.es

Re: Option List in Code (Payment calculator) 15.07.2014 20:00

The reason why I am using an if/elseif statement is that I am using the variable to determine the second input into the power function.

In your example I can't pass the 1-year into the second variable location. ($a=pow((1+$c),$1year);) it will not calculate properly.

So I was using the if statement to determine the length and then place a fixed value into the second variable location
$a=pow((1+$c),1);

The other problem I am having is that the new values are not being used in the variables. Let's say my user hits calculate, gives me the answer, then changes the term and hits calculate, this time is uses the first inputs and gives me the same answer.

Please check out the right handle calculator on www.lifemazing.com

Any help would be appreciated.

Thank you

Re: Option List in Code (Payment calculator) 16.07.2014 09:39

Hello,

First of all, you should change variable name of $1year. Variable should start with a letter or underscore, a number is not allowed as first character in variable. Change it and test it again.

We tested your site and change some fields in form and answers seems to be changing. Please specify what values are 'new' and weĺl test it again.

Regards,
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback