Niccaman Posted May 26, 2009 Share Posted May 26, 2009 var cut1 = document.getElementById('input1').value; var cut2 = document.getElementById('input2').value; var cut3 = document.getElementById('input3').value; var cut4 = document.getElementById('input4').value; var total = cut1+cut2+cut3+cut4; Why does this output '050500' when entering 0,50,50,0 in the input fields? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 Because they're all strings. Try this - var cut1 = parseInt(document.getElementById('input1').value); var cut2 = parseInt(document.getElementById('input2').value); var cut3 = parseInt(document.getElementById('input3').value); var cut4 = parseInt(document.getElementById('input4').value); var total = cut1+cut2+cut3+cut4; Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 26, 2009 Author Share Posted May 26, 2009 Ty that worked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.