Jump to content

Js Concatenate & Calculate


Recommended Posts

New Caspio user and trying to create two javascript actions (concatenate & calculate) in a submission form datapage.  I have the following fields in the form which I am trying to work with: 

 

1: "Quantity" & "Measurement"  | concatenate | "Qty_Plus_Measurement" ("Measurement" is a cascading dropdown)

 

2: "Quantity" & Unit_Price | calculate | "Total_Price"

 

After testing, neither script is working...My footer script is below. 

 

 



<!-- Responsive Code Begin -->
</div>
<!-- Responsive Code End -->


<SCRIPT LANGUAGE="JavaScript">


function concatenate()
{
var position1 = document.getElementById("InsertRecordQuantity").value; 
var position2 = document.getElemenstByName("InsertRecordMeasurement")[0];


var allpositions = position1 + position2;


document.getElementById("InsertRecordQty_Plus_Measurement").value = allpositions; 


}


document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>


<SCRIPT LANGUAGE="JavaScript">


 function calculate()
 {
   var v_price = parseFloat(document.getElementById("InsertRecordUnit_Price").value);
   var v_quantity  = parseFloat(document.getElementById("InsertRecordQuantity").value);
   var v_total  = (v_Unit_Price * v_Quantity);
   document.getElementById("InsertRecordTotal_Price").value = Math.round(v_total);
 }


 /* On submitting the webform, the function calculate is executed */
 document.getElementById("caspioform").onsubmit=calculate;


</SCRIPT>

Link to comment
Share on other sites

Hello bmtadmin,

 

Welcome to Caspio Forum!

 

As far as I know, you can use "onsubmit" action only once.

I have edited your code:

<SCRIPT LANGUAGE="JavaScript">

function concatenate()
{
var position1 = document.getElementById("InsertRecordQuantity").value; 
var dropdown = document.getElemenstByName("InsertRecordMeasurement")[0];
var position2 = dropdown[dropdown.selectedIndex].value;

var allpositions = position1 + position2;

document.getElementById("InsertRecordQty_Plus_Measurement").value = allpositions; 

var v_price = parseFloat(document.getElementById("InsertRecordUnit_Price").value);
var v_quantity  = parseFloat(document.getElementById("InsertRecordQuantity").value);
var v_total  = (v_Unit_Price * v_Quantity);
document.getElementById("InsertRecordTotal_Price").value = Math.round(v_total);
 }

 /* On submitting the webform, the function calculate is executed */
 document.getElementById("caspioform").onsubmit=calculate;

</SCRIPT>

I hope, it helps.

Link to comment
Share on other sites

  • 3 years later...

Hi @bmtadmin,

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 for your total price.

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

×
×
  • Create New...