Forum


Calc Builder Support

Calc Builder support
Forums
No se permite escribir sin estar logado. Por favor, login

Inline results with Sections 15.06.2016 02:57

Hello,

Inline results are not showing actual results when I activate sections. Normally it shows however my customers might want to add more rows of my fields and I need section for that. When I activate sections inline results are just keep refreshing and when I enter values in the fields nothing happens.

What could be the reason for this?

Re: Inline results with Sections 15.06.2016 08:46

Hello,
we guess you're trying to show some inline results inside the section, right? Then you must change a little bit the way to specify outputs, because when using sections, you will have many results to return, one per line.

Let's say you have a default input with 2 fields(input1 and input2), and an inline field (myinlineresult). You have at the code section, for ex:


$myinlineresult=$input1*$input2;


This will work on a default form. Now if you decide to include the 3 fields inside a section, you will have a list of inputs, so you should return a list of outputs. So the inputs will be

$input1[0] and $input2[0] //for the first line
$input1[1] and $input2[1] //for the second line
...
$input1[n] and $input2[n] //for the nth+1 line


at the code you need to specify the result will be a list (array):

$myinlineresult=array();


and then fill the values of each line

$myinlineresult[0]=$input1[0]*$input2[0];
$myinlineresult[1]=$input1[1]*$input2[1];

...etc

as you probably don't know exactly how many lines your user will add to your form, you can do a loop to run over all lines of the inputs, this way:


$myinlineresult=array();

///as the forum strips out some tags of the code, please follow this explanation at this new entry of the tutorial section:

https://www.moonsoft.es/easyblog/entry/55-working-with-sections-inputs-and-inline-results

Thank you

Edited by MSTeam - 15.06.2016 09:00
Moonsoft Team
www.moonsoft.es

Re: Inline results with Sections 15.06.2016 14:00

wow! Many thanks for the prompt reply! I will give it a try and comeback if it works.

Re: Inline results with Sections 17.06.2016 02:25

I think I could not make it work :)

Is it possible to upload an example calculator so I can apply it to mine ?

Re: Inline results with Sections 17.06.2016 03:06

Well. I made your example working and see if I can apply it to my version :)

I also made an example calculator. You guys can download it from the link below;

https://drive.google.com/open?id=0B_RFt-SnVsEYNnItLUxCRDlhaGM

To be honest anything could be done with this component after couple of modifications. Very well made!

Re: Inline results with Sections 17.06.2016 03:18

Another question.

What if we are using matrix table and wanted to use sections with inline results each line? What should we do then?

Re: Inline results with Sections 17.06.2016 03:34

One more thing. I include a field for this calculator but it is optional for my users. When I apply your solution and If I or any user dont enter any value on that optional field calculator does not work and it only shows refreshing icon. When I enter value in that optional field it works on each line or section.

How can we bypass this optional field if it is not filled?

I asked many questions but I am very curious to apply my calculator online.

Waiting your reply.

thank you.

Re: Inline results with Sections 17.06.2016 10:07

Another question.

What if we are using matrix table and wanted to use sections with inline results each line? What should we do then?


Hi,
there's no problem to use matrix to calculate results inside or outside the sections, you only need to use the proper index for rows/columns for each case, so if you had for ex, this line to get one matrix data according to your inputs:

$auxdata=$mymatrix[$input1][$input2];

and now you insert your inputs inside a section, like we've commented above, you only need to use the list syntax for them:

$auxdata=$mymatrix[$input1[0]][$input2[0]];


you can replace the 0 for the dynamic $i index explained above inside the loop.


Hope this helps, regards
Moonsoft Team
www.moonsoft.es

Re: Inline results with Sections 17.06.2016 10:10

One more thing. I include a field for this calculator but it is optional for my users. When I apply your solution and If I or any user dont enter any value on that optional field calculator does not work and it only shows refreshing icon. When I enter value in that optional field it works on each line or section.

How can we bypass this optional field if it is not filled?

I asked many questions but I am very curious to apply my calculator online.

Waiting your reply.

thank you.


Hi,
if the calculator doesn't come back it means it may be getting an error when trying to execute your calculations. Maybe you've set the field as 'optional' but you're using it inside your calculations so they don't work if is empty? Please double check your math expressions to find out if that field is really needed for all cases, you can place a ticket and share your calculator if you can't get it working, we'll take a look and let you know how to fix.

Regards
Moonsoft Team
www.moonsoft.es

Re: Inline results with Sections 17.06.2016 11:57

One more thing. I include a field for this calculator but it is optional for my users. When I apply your solution and If I or any user dont enter any value on that optional field calculator does not work and it only shows refreshing icon. When I enter value in that optional field it works on each line or section.

How can we bypass this optional field if it is not filled?

I asked many questions but I am very curious to apply my calculator online.

Waiting your reply.

thank you.

Hi,
if the calculator doesn't come back it means it may be getting an error when trying to execute your calculations. Maybe you've set the field as 'optional' but you're using it inside your calculations so they don't work if is empty? Please double check your math expressions to find out if that field is really needed for all cases, you can place a ticket and share your calculator if you can't get it working, we'll take a look and let you know how to fix.

Regards


Many thanks for your prompt replies.

I am using it in my calculations because sometimes users need to enter values and sometimes not. It depends on the product they want.

My calculator calculates weight of 1 pc of Plastic bag.

Fields I am using;

Width (Necessary)
Length (Necessary)
Bottom Gusset (Optional)
Thickness (Necessary)

so sometimes customers might want a bag with bottom gusset and sometimes not (Please Google bottom gusset if its unclear what it means). If they dont want it they will leave it empty as usual but calc does not return with result in this case.

Edited by kahen - 17.06.2016 11:58

Re: Inline results with Sections 18.06.2016 10:53

Hi,
ok, we understand the function you want to build. The problem may be your field is optional but you're always using it at your calculation code (so it throws an error if empty)? Depending on your calculator specs, you may need to add any condition at your code so you can perform different calculation in case the optional field is filled or not, if your field is called for ex 'bottom' you can add to your code an 'if/else' block:

if($bottom==""){

//here your calculations in case the field is empty
}
else{
//here your calculations in case the field has any value
}

so you can ensure you don't use the field $bottom inside the section where you know already the field is empty.

Hope this helps, regards
Moonsoft Team
www.moonsoft.es

Re: Inline results with Sections 20.06.2016 13:29

Hi,
ok, we understand the function you want to build. The problem may be your field is optional but you're always using it at your calculation code (so it throws an error if empty)? Depending on your calculator specs, you may need to add any condition at your code so you can perform different calculation in case the optional field is filled or not, if your field is called for ex 'bottom' you can add to your code an 'if/else' block:

if($bottom==""){

//here your calculations in case the field is empty
}
else{
//here your calculations in case the field has any value
}

so you can ensure you don't use the field $bottom inside the section where you know already the field is empty.

Hope this helps, regards


Hi,

Thank you for your solution. I thought "if / else" solution as well but it looked complicated to me. so I found something very simple.

If I enter 0 to my field, my calculator starts working as there is a number entered in the value. So I added this simple javascript code into my calculator;

cb_setValue('alt','0');

(alt is the name of my field)

so Default value of the optional field is 0 to make calculator work in case users want to change it.

Re: Inline results with Sections 20.06.2016 17:17

Hi,
ok, if a default value does the work for your calculator, then you don't need to add js, there is a 'default value' parameter that you can set for each field at your calculator backend->fields tab.

Regards
Moonsoft Team
www.moonsoft.es

Re: Inline results with Sections 20.06.2016 19:18

Oh! I havent seen that option and didnt know that it was giving values to fields! Works like a charm now and solved my problem without js.

Thank you for your patience and help :)

Re: Inline results with Sections 23.06.2016 16:37

Hello,

Its me again!

I am stuck at something.

Is it possible to make a formula of 2 Inline fields and make the formula repeat each time when user clicks add button?

For example lets say I have inline1 and inline2

I want to make $inline3=$inline1*$inline2

Hope I explained clearly.

Edited by kahen - 23.06.2016 17:42

Re: Inline results with Sections 23.06.2016 21:08

Hi,
yes, you can use at your formulas any inline field, results previously calculated or any other variable. The inline calculations will launch everytime you add one section so you only need to add your code to have it working. You only need to ensure you place your code:

$inline3=$inline1*$inline2;

below the other formulas where you calculate values for inline1 and inline2, so the values are already there when you calculate inline3.

Hope this helps, 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

Lo que nuestros clientes opinan de nosotros