OsakaWebbie
Programmer
I have code that clones a section of the DOM and increments a two-digit number at the end of the IDs, names, etc. It works fine except when it gets to "08" - it seems that parseInt("08") and parseInt("09") are zero rather than what they should be. I thought there was something in the rest of my code that was tripping it up, but I kept removing other stuff, including all my jQuery, incrementing and converting back to strings with padding, and even loops, but it never got well - check out this extremely stupid code:
You can try it yourself if you don't believe me, but the result is:
Code:
<html><head>
<script type="text/javascript">
window.onload = function() {
text = "parseInt('01')="+parseInt("01")+"<br>";
text += "parseInt('02')="+parseInt("02")+"<br>";
text += "parseInt('03')="+parseInt("03")+"<br>";
text += "parseInt('04')="+parseInt("04")+"<br>";
text += "parseInt('05')="+parseInt("05")+"<br>";
text += "parseInt('06')="+parseInt("06")+"<br>";
text += "parseInt('07')="+parseInt("07")+"<br>";
text += "parseInt('08')="+parseInt("08")+"<br>";
text += "parseInt('09')="+parseInt("09")+"<br>";
text += "parseInt('10')="+parseInt("10")+"<br>";
text += "parseInt('11')="+parseInt("11")+"<br>";
text += "parseInt('12')="+parseInt("12")+"<br>";
text += "parseInt('13')="+parseInt("13")+"<br>";
document.getElementById('content').innerHTML = text;
}
</script>
</head><body>
<p id="content"></p>
</body></html>
What in the world is going on?parseInt('01')=1
parseInt('02')=2
parseInt('03')=3
parseInt('04')=4
parseInt('05')=5
parseInt('06')=6
parseInt('07')=7
parseInt('08')=0
parseInt('09')=0
parseInt('10')=10
parseInt('11')=11
parseInt('12')=12
parseInt('13')=13