Jump to content
senicholas

Adding 3 Text Fields And Writting Total To Table

Recommended Posts

I have been working the code below, adding 3 text fields and tying to write the total to the field TTL_Crates, but, I cannot get it to work. Any ideas?

 

 

<br />

 

<script language="JavaScript">

 

 

 

function calculate()

 

{

 

   var v_one= parseFloat (document.getElementById("InsertRecordCrate_One_Quantity").value);

 

 

 

  var v_two= parseFloat (document.getElementById("InsertRecordCrate_Two_Quantity").value);

 

 

 

   var v_three= parseFloat (document.getElementById("InsertRecordCrate_Three_Quantity").value);

 

 

 

 

 

   var v_total  = (v_one + v_two + v_three);

 

document.getElementByID(“InsertRecordTTL_Cratesâ€).value= (v_total);  }

 

 

 

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

 

document.getElementById("InsertRecordBid_Order Web Form_1").onsubmit=calculate;

 

Share this post


Link to post
Share on other sites

Hello senicholas,

 

You can try using the following script:

<script language="JavaScript">

function calculate()
{
var v_one = parseFloat(document.getElementById("InsertRecordCrate_One_Quantity").value);
var v_two = parseFloat(document.getElementById("InsertRecordCrate_Two_Quantity").value);
var v_three = parseFloat(document.getElementById("InsertRecordCrate_Three_Quantity").value);

var v_total  = v_one + v_two + v_three;

document.getElementByID(“InsertRecordTTL_Cratesâ€).value = v_total;
}

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

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

</script>

I hope, it helps.

Share this post


Link to post
Share on other sites
Hello senicholas,

 

As far as i know, usually "Hidden" and "Text Area" fields are allowed too. There are some tricks with Dropdowns and Listboxes, Checkboxes and Radiobuttons.

Which Form Element do you use?

 

Could you provide the URL of your page?

Share this post


Link to post
Share on other sites

If I understand correctly, now the following code is used:

 

<script language="JavaScript">

function calculate()
{
   var v_one= parseFloat (document.getElementById("InsertRecordCrate_One_Quantity").value);
   var v_two= parseFloat (document.getElementById("InsertRecordCrate_Two_Quantity").value);
   var v_three= parseFloat (document.getElementById("InsertRecordCrate_Three_Quantity").value);
   var v_total  = v_one + v_two + v_three;
   document.getElementByID(“InsertRecordTTL_Cratesâ€).value= v_total; } document.getElementById("caspioform").onsubmit=calculate;
</script>
 
There are two misprints in the following line
document.getElementByID(“InsertRecordTTL_Cratesâ€).value= v_total; } 
Incorrect quotes and "ID"
 
You can try to change the line as follows:
document.getElementById("InsertRecordTTL_Crates").value= v_total; }

I hope, it helps.

Share this post


Link to post
Share on other sites

Hi @senicholas,

As Caspio had their releases. You can now do this without using JavaScript.  You can check it 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 for your total.

Check these videos for more information:

 

I hope it helps.

Share this post


Link to post
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
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.

Loading...

×
×
  • Create New...