Jump to content
  • 0

Summing currency fields in entry form


ktrav1331

Question

I am a newcomer to JS and cannot seem to get this to work. I have a new record form for a project, in which I have multiple budget fields (currency) which I would like to have totaled to a "Total Direct Cost" field, also in the table/form. I have added several different forms of the JS below in the footer and in an HTML block in my caspio form, but have not been able to get this to work. Any suggestions on formatting, syntax errors, etc. would be much appreicated.

function calculate()

{

var laborbudget = document.GetElementById("InsertRecordLabor_Budget").value;

var materialbudget = document.GetElementById("InsertRecordMaterial_Budget").value;

var rentalbudget = document.GetElementById("InsertRecordRental_Fees_Budget").value;

var totaldirectcost = laborbudget + materialbudget + rentalbudget;

document.getElementById("InsertRecordTotal_Direct_Cost_Budget").value = totaldirectcost;

}

document.getElementById("caspioform").onsubmit=calculate

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

First thing in here is that the last line of the code which calls the function is missing ";":

document.getElementById("caspioform").onsubmit=calculate;

also in all the lines you are assigning value to variables you are using GetElement where it should be getElement:

Change: var laborbudget = document.GetElementById("InsertRecordLabor_Budget").value;

to: var laborbudget = document.getElementById("InsertRecordLabor_Budget").value;

in all these lines:

var laborbudget = document.GetElementById("InsertRecordLabor_Budget").value;

var materialbudget = document.GetElementById("InsertRecordMaterial_Budget").value;

var rentalbudget = document.GetElementById("InsertRecordRental_Fees_Budget").value;

:wink: :wink: :wink: :wink:

let me know if that helped.

Link to comment
Share on other sites

  • 0

Hi @ktrav1331,

As of July 12, 2018, Caspio introduced new features which you can find here: https://howto.caspio.com/release-notes/caspio-bridge-13-0/

This release includes a new feature, Calculated Values in Submission Forms.  This allows you to generate calculations which you can use as your total value for "Total Direct Cost" field. 

Check these videos for more information:

 

 

I 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.

Guest
Answer this question...

×   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.

Loading...
×
×
  • Create New...