HTML Code:
<script type="text/javascript">
var elName;
window.onload=function()
{
var el = document.forms[0].elements;
for(var i=0;i<el.length;i++)
el[i].onfocus=function()
{
elName=this.getAttribute('name');
}
}
</script>
</head>
<form>
<a href="#" onclick="alert(elName?'The element having the name of \''+elName+'\' was focused.':'No element was focused.'); return false">"Which element has the focus?"</a><br>
<input name="mytxt1" type="text"><br>
<input name="mytxt2" type="text"><br>
<input name="mytxt3" type="text"><br>
<input name="mytxt4" type="text"><br>
<input name="mytxt5" type="text"><br>
</form>
Bookmarks