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 and $input2 //for the first line
$input1 and $input2 //for the second line
...
$input1 and $input2 //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=$input1*$input2;
$myinlineresult=$input1*$input2;
...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
wow! Many thanks for the prompt reply! I will give it a try and comeback if it works.
I think I could not make it work :)
Is it possible to upload an example calculator so I can apply it to mine ?
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!
Another question.
What if we are using matrix table and wanted to use sections with inline results each line? What should we do then?
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.
Another question.
What if we are using matrix table and wanted to use sections with inline results each line? What should we do then?
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.
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
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,
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,
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
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 :)
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
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
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?