Hi Everyone,

I hope you are enjoying your weekend and not working too hard.

I'm still trying to get my head around js, and was hoping someone may have some insights to help me with the next steps on a form I am creating.

I have an order form that is going to be dynamically created.
I am able to successfully pass the quantity value upon user input for field 1.
Basically I'm using onchange() to pass the quantity value to the script.
The id of the price field is of the format unit-price-0, unit-price-1, etc.
Each line item's subtotal should update before going onto the next line item.

Here's the js function. Each line item has its own unit-cost, quantity, and subtotal.
Any help would be so appreciated.

One suggestion was to "have form api write those hidden fields after each element is created"
Not sure how to accomplish that.

   function calcPrice() {

     // Get the Quantity From Form Field //
   unitCost = document.getElementById ('edit-price-0').value;
   theQty = document.getElementById ('edit-quantity').value;

     subOrderCost = theQty * unitCost;

     //Line Item Cost //
     subtotalCost = subOrderCost;
     //
     subtotalCostDisplay = addCommas(subtotalCost.toFixed(2));
     //
     subtotalCostValue = subtotalCost.toFixed(2);
     //
     //// Display Cost To User //
     document.getElementById('edit-subtotal').value = "$" +
   subtotalCostDisplay;
   }

--
Karyn

Reply via email to