|
-
May 19th, 2005, 10:50 AM
#1
Thread Starter
Junior Member
Can't add innerText values?
Hello,
My innerText values are concatenating instead of added. Any ideas?
Thanks!
Code:
var txtQtyBox = document.getElementById("txtPrinterQuantity2");
var lblPriceBox = document.getElementById("lblPrinterAmount2");
var lblPriceBoxb = document.getElementById("lblPrinterAmount2b");
var lblPriceBoxc = document.getElementById("lblPrinterAmount2c");
OOTotal += (txtQtyBox.value * (lblPriceBox.innerText+lblPriceBoxb.innerText+lblPriceBoxc.innerText));
-
May 19th, 2005, 11:06 AM
#2
Frenzied Member
Re: Can't add innerText values?
As they are innerText they are strings not numerical values - you need to convert them to the numeric type you need before adding. + used with strings just concatenates!
DJ
If I have been helpful please rate my post. If I haven't tell me!
-
May 19th, 2005, 12:01 PM
#3
Re: Can't add innerText values?
try this:
Code:
<script type="text/javascript">
<!--
var txtQtyBox = document.getElementById("txtPrinterQuantity2");
var lblPriceBox = document.getElementById("lblPrinterAmount2");
var lblPriceBoxb = document.getElementById("lblPrinterAmount2b");
var lblPriceBoxc = document.getElementById("lblPrinterAmount2c");
OOTotal += (eval(txtQtyBox.value) * (eval(lblPriceBox.innerText) + eval(lblPriceBoxb.innerText) + eval(lblPriceBoxc.innerText)));
//-->
</script>
Cheers,
RyanJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|