Jump to content

Store Value Of Calculated Field

Recommended Posts

I need to do a simple calculation on a datapage and store the result in a field in the table. However the result is not being stored so I'm doing something stupid but can't immediately see what despite looking at the few examples here in the forum. So  I hope someone can help me out.


The table has a lot of fields, two of which are number (general) fields called Miles and usual_co2. The miles figure is entered into the dataform by the user. The usual_co2 is a cascading listbox based on the type of vehicle they are using. That figure is saved with no problem in the table.


I need to multiply the miles by the usual_co2 and store the result in the field calculated_co2 (also a number (general field) when the form is saved. The javascript calculation I have put into the footer of the datapage is:


 function calculate()
   /* Retrieve the value of the field Miles and store in a variable v_miles */
   var v_miles = parseInt(document.getElementById("InsertRecordMiles").value);

   /* Retrieve the value of the field usual_co2 and store in a variable v_usual_co2 */
   var v_usual_co2 = parseInt(document.getElementById("InsertRecordusual_co2").value);

   /* Multiply the value Miles and usual_co2 to obtain v_calculated_co2 */
   var v_calculated_co2=(v_miles*v_usual_co2);

   document.getElementById("InsertRecordcalculated_co2").value = v_calculated_co2);



Can someone see what is wrong here? Thanks.



Link to comment
Share on other sites

Hi Rob,


To get the value of a dropdown element you need to use the following syntax:




Try to replace them with the one above and see if that fixes the issue. If not, provide the page URL if possible so I can see any error using IE development tool (F12) or Firebug in FF. You can also use these tools for debugging your code.




Link to comment
Share on other sites

  • 1 year later...

Calculated field in results page is generated on the fly each time results page is loaded. It cannot be saved into the table. Calculated field in web form can be saved into the table after submission by using JavaScript. In details page, you can create another field and make it hidden, then select "DataSource Fields" from "On load assign" dropdown and select your calculated field from the list. This enables passing the calculated field as parameter into the new field. Make sure passing parameter in your DataPage is enabled from the second wizard screen.

Link to comment
Share on other sites

  • 3 years later...

I am not able to select the "Calculated Field" from the "Data Source Fields" drop down menu, it doesn't appear there. 


I am in the same situation. I have a "Calculated Field" that runs a calculation which I need stored in a table. I am unable to get this calculated value to get stored in the table currently. 


Any assistance would be greatly appreciated!

Link to comment
Share on other sites

  • 7 months later...

Hi @YourSolutions,


I understand that you want to save the result of the calculated field into the table. Unfortunately, Calculated Fields are for display only. What I thought as a workaround is to have triggered action that will calculate the value upon inserting of data and will be saved into the table. You may refer to this link for more details regarding triggered action: https://howto.caspio.com/tables-and-views/triggered-actions/


Hope this helps.




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...