Hi:
I have mentioned the java script code below my need is i have to implement the same code with "For" loop which inturn gives me the same result.I was tried but it gives me diffrent out .Can any one solve this issue.
Thanks
Code(Without For Loop):
<html>
<head>
<script language='javascript'>
function init()
{
document.getElementById('btn' + 0).onclick = function(){display(0);};
document.getElementById('btn' + 1).onclick = function(){display(1);};
document.getElementById('btn' + 2).onclick = function(){display(2);};
document.getElementById('btn' + 3).onclick = function(){display(3);};
document.getElementById('btn' + 4).onclick = function(){display(4);};
document.getElementById('btn' + 5).onclick = function(){display(5);};
document.getElementById('btn' + 6).onclick = function(){display(6);};
document.getElementById('btn' + 7).onclick = function(){display(7);};
}
function display(value)
{
alert('you clicked the Button' + value);
}
</script>
</head>
<body onload="init();">
<input type='button' id='btn0' value="Button0">
<input type='button' id='btn1' value="Button1">
<input type='button' id='btn2' value="Button2">
<input type='button' id='btn3' value="Button3">
<input type='button' id='btn4' value="Button4">
<input type='button' id='btn5' value="Button5">
<input type='button' id='btn6' value="Button6">
<input type='button' id='btn7' value="Button7">
</body>
</html>