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));
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
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