function makeLabelsWork() {if (!document.getElementsByTagName) return false;
var allforms = document.getElementsByTagName('form'); for (var formcount=0;formcount<allforms.length;formcount++) { var labels =
document.forms[formcount].getElementsByTagName('label');
for (var i=0;i<labels.length;i++) { if (!labels[i].getAttribute('for')) break; labels[i].formfield = labels[i].getAttribute('for');labels[i].formnumber = formcount;
labels[i].onclick = function() {
eval('document.forms['+this.formnumber+'].'+this.formfield+'.focus()');
}
}
}
}
You'll need to call the function when the document loads:
window.onload = function() {makeLabelsWork();
}
It isn't targetted at any specific browser(s). If the browser already does this, then the script is just duplicating what's already there. If the browser doesn't have this behaviour by default, it has now.
HTH,
Jeremy
-- Jeremy Keith
a d a c t i o
http://adactio.com/
****************************************************** The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help ******************************************************
