Camillia
asked on
Javascript concats instead of adding
I have this Javascript code. The addition line doesnt add. It concats. For example, i have 2 values: 100.00 and 10.00 . It comes out as 10.00100.00
I googled and "+" is the right thing to use. Not sure why it's not adding:
I googled and "+" is the right thing to use. Not sure why it's not adding:
<script type="text/javascript">
var amount = 0.00;
function prices(price) {
var tempAmount = document.getElementById('<%=x_amount.ClientID %>');
alert(tempAmount.value);
amount = price + tempAmount.value;
alert(amount);
tempAmount.value = amount;
// alert(amount.value);
}
</script>
ASKER
no, still comes out as this 10.00100
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
http://www.w3schools.com/jsref/jsref_parsefloat.asp