Create Table
-
Hello team,
I have a long calculation having 100 lines of code.Based many inputs like fieldname1,fieldname2 etc , it calculates the fieldname3.
Now I want that this calculation is repeated by varying the value of fieldname1 automatically by some fixed increments and fieldname3 is recalculated automatically.
Finally this fieldname1 and fieldname3 are presented to user as a table of fieldname1 and fieldname3.
Please support.
Regards,
-
This topic was modified 3 years, 11 months ago by
hheyhey568.
-
This topic was modified 3 years, 11 months ago by
-
Hello @hheyhey568
You should generate the table as part of the equation and visualize it in another field, like an “HTML Content” field.
For example, assuming you have the equation
(fieldname1+fieldname3)*fieldname2, and you want to generate a table by increasing the fieldname2 value from 1 to 10:1. Insert an “HTML Content” field in the form with a div tag as its content where display the table:
<div class="table-here"></div>2. Edit the equation as follows:
(function(){ var table = '<table><thead><tr><th>Field Value</th><th>Result</th></tr></thead>'; table += '<tbody>'; for(var i = 1; i <= 10; i++) { table += '<tr><td>'+(fieldname2+i)+'</td><td>'+((fieldname1+fieldname3)*(fieldname2+i))+'</td></tr>'; } table += '</tbody></table>'; jQuery('.table-here').html(table); return table; })()Best regards.
Thanks for quick reply.
In my case I have the following equation.(function(){
var PipeID;
PipeID=fieldname14*25.4/1000;var PipeOD;
PipeOD=fieldname62*25.4/1000;var CSArea;
CSArea=Math.PI/4*PipeID*PipeID;var FlowRate;
if(fieldname65==”m3/hr”) FlowRate=fieldname64;
if(fieldname65==”US GPM”) FlowRate=fieldname64*0.22712470704;var Velocity;
Velocity=(FlowRate/3600)/CSArea;var FroudeN;
FroudeN=Velocity/POW(9.81*PipeID,0.5);var Submerge;
Submerge=PipeOD*(1+2.3*FroudeN);getField(68).setVal(PREC(Submerge,2));
var OutputS;
if(fieldname66==”m”) OutputS=Submerge;
if(fieldname66==”ft”) OutputS=Submerge*3.28084;
if(fieldname66==”inch”) OutputS=Submerge*3.28084*12;return PREC(OutputS,2);
})()
I want to vary PipeID and prepare a table of PipeID vs OutputS.
How to do it please let me know.
thanks
Hello,
Continuing with the previous example, the equation can be edited as follows:
(function(){ var table = '<table><thead><tr><th>PipeID</th><th>OutputS</th></tr></thead>'; table += '<tbody>'; for(var i = 0; i < 10; i++) { var PipeID; PipeID=(fieldname14+i)*25.4/1000; var PipeOD; PipeOD=fieldname62*25.4/1000; var CSArea; CSArea=Math.PI/4*PipeID*PipeID; var FlowRate; if(fieldname65=="m3/hr") FlowRate=fieldname64; if(fieldname65=="US GPM") FlowRate=fieldname64*0.22712470704; var Velocity; Velocity=(FlowRate/3600)/CSArea; var FroudeN; FroudeN=Velocity/POW(9.81*PipeID,0.5); var Submerge; Submerge=PipeOD*(1+2.3*FroudeN); getField(68).setVal(PREC(Submerge,2)); var OutputS; if(fieldname66=="m") OutputS=Submerge; if(fieldname66=="ft") OutputS=Submerge*3.28084; if(fieldname66=="inch") OutputS=Submerge*3.28084*12; OutputS = PREC(OutputS,2); table += '<tr><td>'+PipeID+'</td><td>'+OutputS+'</td></tr>'; } table += '</tbody></table>'; jQuery('.table-here').html(table); return table; })()Please, note I’m increasing the value of the fieldname14 field when generating the PipeID,
PipeID=(fieldname14+i)*25.4/1000;It is only an example. You should increase the values as you want.
Best regards.
Hello Team,
Thank you very much. It is working perfectly.Two more features to be added if possible pls.
Feature 1)
Instead of increasing the PipeID by adding 1 to fieldname14 of above example , what if I want to vary the fieldname14 by fixed value like,A) PipeID when Fieldname14=0.5
B) PipeID when Fieldname14=0.8
C) PipeID when Fieldname14=1.5 and so on upto 10 entries in the table.The reason is PipeID is calculated based on fieldname14 and filename14 is the result of two dropdown fields.
Feature 2)
Is there a possibility to vary the value of PipeID based on value of dropdown fields. Means I add a dropdown field as fieldname14 and it has values in dropdown as 0.5 , 0.8 , 1.5 , 2 and so on. So the code need to jump from one value of dropdown to another value of dropdown.
If this is not possible then above feature 1 can be used where I need to define the fixed value of fieldname14.
regards,
Hello @hheyhey568
In this case, you should create an array with the values and walk through this array.
The piece of code to vary would be:
var values = [0.5,0.8,1.5]; for(var i in values) { var PipeID; PipeID=(fieldname14+values[i])*25.4/1000;I’m sorry, but the support service does not cover the implementation of user projects (forms or formulas). If you need us to implement your project, you can contact us through our website: Custom Coding Service
Best regards.
Thank you.
Is there a way in which we can use this table result of above example and then plot a chart based on this result table values?
X axis = PipeID
Y Axis = OutputSHello @hheyhey568
Yes, that’s possible. You must use the CFFCHART operation to generate the chart. The “PipeID” list would be used for labels and “OutputS” for the dataset data list.
More information by reading the following blog post:
https://cff.dwbooster.com/blog/2019/05/27/charts
Best regards.
The topic ‘Create Table’ is closed to new replies.