Do you have  numeric default set for your #itemPrice# variable?   If  
not, you'll either have to pull the window.onload function or set a  
numeric default.

Also, does DOM of your page validate?

Jon

On Jan 13, 2007, at 1:50 PM, Doug Brown wrote:

> Jon, Thanks for the help. When I run the code I get NaN
>
>
>
>
> Doug B.
> ----- Original Message -----
> From: "Jon Clausen" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[email protected]>
> Sent: Saturday, January 13, 2007 11:31 AM
> Subject: Re: A little JS help!!
>
>
>> I'd suggest changing your HTML a bit to make it easier.  I removed
>> the calculate button because you don't need it, but you could always
>> put it back and set the onclick to setTotal().
>>
>> With the changed HTML the following will work:
>>
>> <script type="text/javascript" language="javascript">
>> function setTotal() {
>> var calcs = document.getElementsByTagName('input');
>> var qty = 0;
>> var price = 0;
>> for(var i=0; i < calcs.length; i++) {
>> if (calcs[i].getAttribute('name') == "price"){
>> price = (price+calcs[i].value);
>> };
>> if (calcs[i].getAttribute('name') == "AQuantity"){
>> qty = (qty+calcs[i].value);
>> };
>> };
>> document.getElementById("total-price").innerHTML = (qty * price);
>> }
>> window.onload = function(){
>> setTotal();
>> }
>> </script>
>>
>> <tr>
>>      <td width="70" class="bblackfont">Your Offer:</td>
>>      <td width="80" class="nblackfont"><input type="text"
>> name="AQuantity" value="1" style="width: 40px;" onblur="setTotal 
>> ()"></
>> td>
>>      <td width="590" class="nblackfont"><input type="text"
>> name="price" value="#numberFormat(itemPrice)#" style="width:50px;"
>> onblur="setTotal()"></td>
>>      <td id="total-price"><!---totalPrice goes here---></td>
>> </tr>
>>
>>
>>
>>
>> On Jan 13, 2007, at 12:56 PM, Doug Brown wrote:
>>
>>> I have the following little code snippet and what I would like to
>>> do is update the totalPrice if the quantity is changed by the user.
>>>
>>>    <TR>
>>>     <TD width="70" class="bblackfont">Your Offer:</TD>
>>>     <TD width="80" class="nblackfont"><input type="text"
>>> name="AQuantity" value="1" style="width: 40px;"></TD>
>>>     <TD width="590" class="nblackfont"><input type="text"
>>> name="price" value="#numberFormat(itemPrice)#" style="width:
>>> 50px;"></TD>
>>>     <TD><!---totalPrice goes here---></TD>
>>>     <TD><image src="images/calulator.gif" alt="calculate"
>>> onClick="something"></TD>
>>>    </TR>
>>>
>>>
>>>
>>>
>>> Doug B.
>>>
>>>
>>
>>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266507
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to