<div>Hi,</div><div><br></div><div>What drupal version are you using? You mmaight want to look at AHAH which is made to work with dynamic forms. It is built-in in Drupal 6. Additionaly there is an excellent AHAH Helper module, which extends functionality of built-in AHA. You dont really need to write any js if the operations are simple, like in your situation. Some usefull links: <a href="http://drupal.org/node/348475">http://drupal.org/node/348475</a></div>
<div><br></div><br clear="all">Kindest regards,<br>Adam Ludwinski<br>mobile: +48 606 107 297<br><a href="mailto:adam.ludwinski@meant4.com">adam.ludwinski@meant4.com</a><br><a href="http://www.meant4.com">http://www.meant4.com</a><br>
<br><br><div class="gmail_quote">On 21 February 2010 20:51, Karyn Cassio <span dir="ltr"><<a href="mailto:karyn@karyncassio.com">karyn@karyncassio.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000">
Hi Everyone,<br>
<br>
I hope you are enjoying your weekend and not working too hard.<br>
<br>
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.<br>
<br>
I have an order form that is going to be dynamically created.<br>
I am able to successfully pass the quantity value upon user input for
field 1.<br>
Basically I'm using onchange() to pass the quantity value to the script.<br>
The id of the price field is of the format unit-price-0, unit-price-1,
etc.<br>
Each line item's subtotal should update before going onto the next line
item.<br>
<br>
Here's the js function. Each line item has its own unit-cost, quantity,
and subtotal.<br>
Any help would be so appreciated.<br>
<br>
One suggestion was to "have form api write those hidden fields after
each element is created"<br>
Not sure how to accomplish that.<br>
<blockquote>function calcPrice() {<br>
<br>
// Get the Quantity From Form Field //<br>
unitCost = document.getElementById ('edit-price-0').value; <br>
theQty = document.getElementById ('edit-quantity').value;<br>
<br>
subOrderCost = theQty * unitCost;<br>
<br>
//Line Item Cost //<br>
subtotalCost = subOrderCost;<br>
//<br>
subtotalCostDisplay = addCommas(subtotalCost.toFixed(2));<br>
//<br>
subtotalCostValue = subtotalCost.toFixed(2);<br>
//<br>
//// Display Cost To User //<br>
document.getElementById('edit-subtotal').value = "$" +
subtotalCostDisplay;<br>
}<br>
</blockquote>
<pre cols="72">--
Karyn</pre>
</div>
</blockquote></div><br>