javascript - Specific value element input not read by -
i dont know if browser bug or else, because have tested on chrome , firefox. same result. tried input value element 1,10,100 identified. this's code.
html
<input id="items" type="text" placeholder="title" value=""> <input id="start" type="text" placeholder="start" value=""> <input id="end" type="text" placeholder="end" value=""> <input id="btn" type="submit" value="generate"><br><br> <div id="output" contenteditable="true"></div>
javascript
<script> var btn = document.getelementbyid('btn') var output = document.getelementbyid('output'); btn.addeventlistener('click', function(){ var items = document.getelementbyid('items').value; var = document.getelementbyid('start').value; var e = document.getelementbyid('end').value; for(i; i<=e; i++){ output.innerhtml += items+'/'+i; } }, false); </script>
it not generate if start value input element not 1,10,100. how can make work? start 2,3,4,5,6,7,8,9?
you need convert values integers
:
var = parseint( document.getelementbyid('start').value, 10 ); var e = parseint( document.getelementbyid('end').value, 10 );
Comments
Post a Comment