Hi, I’m trying to write a script grabs all inputs on a page and listens for an onblur event. Pretty simple right? Consider the following code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script type="text/javascript">
window.onload = function() {
var r = document.getElementsByTagName('input');
for(var i = 0; i<= r.length; ++i) {
r[i].onblur = alert('this one =' + i );
}
}
</script>
</head>
<body>
<input type="text" />
<input type="text" />
<input type="text" />
</body>
</html>
This code runs through and alerts out for all 3 inputs on pageload. Why is this? I need it to wait until the element loses focus before the alert is alerted.