Jump to content
  • 0

Calculate a field value on WebForm submission


EBickmann
 Share

Question

I'm having trouble with a script. I understand that I can add to the footer of a submission DP a script that should take two "user" inputted values (Tool_Retail_Value and Tool_Sug_Rental_Rate) and perform a calculation using them and then take the result and put it back into the table into a third field (Tool_Daily_Rate).

So what's wrong?

function calculate()

{

   var rval = document.getElementById("InsertRecordTool_Retail_Value").value);

   var rrate = document.getElementById("InsertRecordTool_Sug_Rental_Rate").value);

   var drate = Math.abs(rval * rrate);

   document.getElementById("InsertRecordTool_Daily_Rate").value=drate;

}

/* On submitting the webform, the function calculate is executed */

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

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi,

I can see that the JavaScript has syntactical errors. I can see two unmatched parenthesis

var rval = document.getElementById("InsertRecordTool_Retail_Value").value);

and

var rrate = document.getElementById("InsertRecordTool_Sug_Rental_Rate").value);

Fix that first and then see if the rest of it works. You can look here for the correct syntax and use of that technic:

http://forums.caspio.com/viewtopic.php?f=14&t=12155

Link to comment
Share on other sites

  • 0

I'd spotted that too.... but with even the correction it still doesn't play nicely...

function calculate()

{

   var rval = document.getElementById("InsertRecordTool_Retail_Value").value;

   var rrate = document.getElementById("InsertRecordTool_Sug_Rental_Rate").value;

   var drate = (rval * rrate);

   document.getElementById("InsertRecordTool_Daily_Rate").value=(drate);

}

/* On submitting the webform, the function calculate is executed */

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

Link to comment
Share on other sites

  • 0

Hi @EBickmann,

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 to calculate Tool_Retail_Value field and Tool_Sug_Rental_Rate field and put it to Tool_Daily_Rate. 

Check these videos for more information:

 

 

 

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

×
×
  • Create New...