javascript - Generate list using two input value? -


this question has answer here:

<input id="in1" value="1"> <input id="in2" value="5">  var text = ""; var t = document.queryselector("#in1").value; var s = document.queryselector("#in2").value; (; t < s+1; t++) {     text += "list " + t + "<br>"; } 

i got 1 problem , 1 question. problem : when using +1 loop , list generated 1 50 instead of 1 5.

the question. how add 0 in front of 1 9 if <input id="in2" value="11">

result:

list 01 list 02 list 03 list 04 list 05 list 06 list 07 list 08 list 09 list 10 list 11 

that because s string. s+1 51 instead of 6. have convert integer.

for (; t < parseint(s)+1; t++) { 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -