Forum


Calc Builder Support

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

Code for Multiple Option Matrix 02.01.2016 21:06

Hello- I am trying to write the code to calculate two variables after the user selects from 3 option fields.

When the user selects from>>>

OPTION 1
OPTION 2
OPTION 3

Then when they press calculate, then I want it to display VARIABLE 1 and VARIABLE 2.

I have this set up in a matrix with the following columns.
OPTION 1, OPTION 2, OPTION 3, VARIABLE 1, VARIABLE 2

Screen Shots can be sent if you give me an email address.

Thanks!!!!

Re: Code for Multiple Option Matrix 03.01.2016 11:42

Hello,
if we've understood properly, you have two values returned for each combination of the 3 values of your option fields. If you build the matrix with separated column, you will have to loop over all rows of the matrix to check if the combination matches and then return the value. It's a valid solution, but we can suggest another structure to recover the values with a single line of code, the approach is to build the matrix using as first column (the key) the combination of the values:

(Key column) VARIABLE1 VARIABLE2

o11#o21#o31 result1 result2
o12#o22#o32 result3 result4
o13....


being o1x the different values for option1, o2x values for option2...etc

now at the code, you could use the key to return both values, if your matrix is called,for ex, 'resultmatrix':


$key=$option1."#".$option2."#".$option3;

$value1=$resultmatrix[$key]["VARIABLE1"];
$value2=$resultmatrix[$key]["VARIABLE2"];




If you need further help, you can attach screenshots and we can share code at the helpdesk.

Regards

Edited by MSTeam - 03.01.2016 11:43
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