Jump to content

2 functions in a script one works


Recommended Posts

Here's what it looks like, I can't figure out why calculate2 function won't enter data into the table.

 

<SCRIPT LANGUAGE="JavaScript">

 function calculate()
 {
   var v_field1 = parseFloat(document.getElementsByName("cbParamVirtual2")[0].value);
if (isNaN(v_field1)) v_field1  = 0;
   var v_field2  = parseFloat(document.getElementById("InsertRecordPrincipal_Portion").value);
if (isNaN(v_field2)) v_field2  = 0;
var v_field3  = parseFloat(document.getElementById("InsertRecordAdditional_Principal").value);
if (isNaN(v_field3)) v_field3  = 0;
   var v_total  = (v_field1 - v_field2 - v_field3);
   document.getElementById("InsertRecordPrincipal_Balance").value = (v_total);

 }

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

function calculate2()
 {
   var v_field1 = parseFloat(document.getElementsByName("cbParamVirtual2")[0].value);
if (isNaN(v_field1)) v_field1  = 0;
   var v_field4  = parseFloat(document.getElementById("InsertRecordInterest_Rate").value);
if (isNaN(v_field4)) v_field4  = 0;

   var v_total  = (v_field1 * v_field4/1200);
   document.getElementById("InsertRecordInterest_Portion").value = (v_total);

 }

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


</SCRIPT>

Link to comment
Share on other sites

May thank you for time trying to help me.

The first calculate works stand alone.   When I add the calculate2 neither one works.  here is what I have in the footer.

<SCRIPT LANGUAGE="JavaScript">

 function calculate()
 {
   var v_field1 = parseFloat(document.getElementsByName("cbParamVirtual2")[0].value);
if (isNaN(v_field1)) v_field1  = 0;
   var v_field2  = parseFloat(document.getElementById("InsertRecordPrincipal_Portion").value);
if (isNaN(v_field2)) v_field2  = 0;
var v_field3  = parseFloat(document.getElementById("InsertRecordAdditional_Principal").value);
if (isNaN(v_field3)) v_field3  = 0;
   var v_total  = (v_field1 - v_field2 - v_field3);
   document.getElementById("InsertRecordPrincipal_Balance").value = (v_total);

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

function calculate2()
 {
   var v_field1 = parseFloat(document.getElementsByName("cbParamVirtual2")[0].value);
if (isNaN(v_field1)) v_field1  = 0;
   var v_field4  = parseFloat(document.getElementById("InsertRecordInterest_Rate").value);
if (isNaN(v_field4)) v_field4  = 0;

   var v_total  = (v_field1 * v_field4/1200);
   document.getElementById("InsertRecordInterest_Portion").value = (v_total);

 }

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

</SCRIPT>

Link to comment
Share on other sites

22 hours ago, dannylipman said:

May thank you for time trying to help me.

The first calculate works stand alone.   When I add the calculate2 neither one works.  here is what I have in the footer.

<SCRIPT LANGUAGE="JavaScript">

 function calculate()
 {
   var v_field1 = parseFloat(document.getElementsByName("cbParamVirtual2")[0].value);
if (isNaN(v_field1)) v_field1  = 0;
   var v_field2  = parseFloat(document.getElementById("InsertRecordPrincipal_Portion").value);
if (isNaN(v_field2)) v_field2  = 0;
var v_field3  = parseFloat(document.getElementById("InsertRecordAdditional_Principal").value);
if (isNaN(v_field3)) v_field3  = 0;
   var v_total  = (v_field1 - v_field2 - v_field3);
   document.getElementById("InsertRecordPrincipal_Balance").value = (v_total);

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

function calculate2()
 {
   var v_field1 = parseFloat(document.getElementsByName("cbParamVirtual2")[0].value);
if (isNaN(v_field1)) v_field1  = 0;
   var v_field4  = parseFloat(document.getElementById("InsertRecordInterest_Rate").value);
if (isNaN(v_field4)) v_field4  = 0;

   var v_total  = (v_field1 * v_field4/1200);
   document.getElementById("InsertRecordInterest_Portion").value = (v_total);

 }

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

</SCRIPT>

 

Link to comment
Share on other sites

There is no syntax error in here as far as I see unless there is an issue with the second script. To figure it out remove the first part and only add the second one see if that works:

 <SCRIPT LANGUAGE="JavaScript">


function calculate2()
 {
   var v_field1 = parseFloat(document.getElementsByName("cbParamVirtual2")[0].value);
if (isNaN(v_field1)) v_field1  = 0;
   var v_field4  = parseFloat(document.getElementById("InsertRecordInterest_Rate").value);
if (isNaN(v_field4)) v_field4  = 0;

   var v_total  = (v_field1 * v_field4/1200);
   document.getElementById("InsertRecordInterest_Portion").value = (v_total);

 }

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

</SCRIPT> 

 

Link to comment
Share on other sites

  • 5 months later...

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