Jump to content

Javascript help needed


Recommended Posts

Can someone help with this javascript please...I'm using a submission form and one of the fields in the calculation is a cascading dropdown with  a parent of Merchandise_ID and the other is a text input field.  Not sure why its not working, but nothing is showing up in the destination field.

 

<strong><span style="color:#000000;"></span></strong>
<strong><span style="color:#000000;">
<div id="mypage1">
</div>
<SCRIPT LANGUAGE="JavaScript">

 function calculate()
 {
 var Gross_Qty_Sold = isNaN((parseFloat(document.getElementById("InsertRecordGross_Qty_Sold").value)))?0:(parseFloat(document.getElementById("InsertRecordGross_Qty_Sold").value));

   var Merchandise_Cost = isNaN((parseFloat(document.getElementsByName("InsertRecordMerchandise_ID_Merchandise_Cost")[0].value)))?0:(parseFloat(document.getElementsByName("InsertRecordMerchandise_ID_Merchandise_Cost")[0].value));

     var total= (Gross_Qty_Sold * Merchandise_Cost);

document.getElementById("mypage1").innerHTML=' $'+total ;
document.getElementById("InsertRecordGross_COGS").value=total.toFixed(2) ;

 }


document.getElementById("InsertRecordGross_Qty_Sold").onchange=calculate;
document.getElementsByName("InsertRecordMerchandise_ID_Merchandise_Cost")[0].onchange=calculate;


calculate();
</SCRIPT>
</span></strong>

Link to comment
Share on other sites

Hi zalipresents, 

 

What is this? 

17 hours ago, zalipresents said:

?0:

 

17 hours ago, zalipresents said:

("InsertRecordMerchandise_ID_Merchandise_Cost")[0]

If I understand correctly, you use Cascading Field as a trigger for calculation?

 

If yes, then I am afraid It is not possible.

Perhaps, it is possible for .onsubmit action. ( Not sure).

 

Aurora

 

 

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...
×
×
  • Create New...