Jump to content
  • 0

Adding Fields Not Working With Cascading Dropdown Values


bmarineau

Question

I have a Submission form that has a Dropdown for "Product" and the next field uses a Cascading Dropdown for "Price".  The following fields are "Additional Charges" and "Discounts".  I want the next field to Total the previous three.

 

I have placed the following code in the Footer of the Submission form:

 

 

<SCRIPT LANGUAGE="JavaScript">
 
function summation()
{
 
var Cost = document.getElementById("InsertRecordPrice").value;
var Additional_Charge = document.getElementById("InsertRecordAdditional").value;
var Disc = document.getElementById("InsertRecordDiscount").value;
 
var Total_Invoice = parseFloat(Cost) + parseFloat(Additional_Charge) + parseFloat(Disc);
 
document.getElementById("InsertRecordTotal").value = Total_Invoice;
 
}
 
document.getElementById("caspioform").onsubmit=summation;
</SCRIPT>
 
 
 
When Price is a cascading dropdown, I do not get a value in the "Total" field.  If I change price to a standard dropdown with custom values the above script works perfectly.
 
In a perfect world, I really don't need a cascading dropdown for Price if I could figure another way to get the number into the field.  The dropdowns are from a separate table called with the product name as column 1 and price as column 2.
 
Any ideas on why this would be misbehaving?
 
Thanks.
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

If you have a dropdown and cascading you should refer to them by name since each time page loads the ID changes. So you need to have:

 

document.getElementsByName("ID")[0].value;

 

 

I could not get the statement to work, until I played around with the parent dropdown.  I had both a static value "Select" with an empty value and the table of values.  I changed the empty value to "0" and it started working.

 

On another note, I had posted the question twice since I didn't see it appear on the forum for a few days so assumed I did something wrong when I posted.  The second post was answered as well with a different solution that works as well.  Thank you for the reply!

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