This code is finally working, but for some reason no matter which button i click on, it is always returning "9". It should be firing the alert(x), where x is the x index value for that particular addEventListener
This is just some sample code that i will later turn into an HTML5 File Manager
Code:
.addEventListener('click', function (e) {alert(x);},
Code:
<html> <script type="text/javascript"> document.addEventListener('DOMContentLoaded', DOMLoadedEventFunction, false); function DOMLoadedEventFunction () { for(var x = 0; x < 9; x++) { document.getElementById('btn' + x).addEventListener('click', function (e) {alert(x);}, false); } } </script> <body> <input type="button" id="btn0" value="1"> <input type="button" id="btn1" value="2"> <input type="button" id="btn2" value="3"> <input type="button" id="btn3" value="4"> <input type="button" id="btn4" value="5"> <input type="button" id="btn5" value="6"> <input type="button" id="btn6" value="7"> <input type="button" id="btn7" value="8"> <input type="button" id="btn8" value="9"> <input type="button" id="btn9" value="10"> </body> </html>
This is just some sample code that i will later turn into an HTML5 File Manager
Comment