We have a massive java application to be made ADA compliant. We want onfocus
and onblur events for each text field. The best way seems to be javascript,
by cycling through all the nodes recursively after page load, and attaching
the events. We already cycle through everything to set tabs. If nodename is
LABEL, we should be able to use the FOR attribute, get the object
referenced, and attach events on that object.
When cycling through nodes, if I get to a label I can print the attribute
collection, and there is a FOR having the correct value for the associated
text object. I can't get any further than that.
This is a piece of code:
if (child.nodeName =='LABEL') {
//var sss = ''+child.attrib utes.length+"\n ";
//for (var k=0;k<child.att ributes.length; k++) sss +=
''+child.attrib utes[k].nodeName+'='+c hild.attributes[k].nodeValue+"\n" ;
//alert(sss);
try {
var cont = child.attribute s.getNamedItem( "for");
alert(''+cont.n odeName);
cont.attacheven t('onfocus',ale rt("xxx"));
cont.attacheven t('onblur',aler t("zzz"));
}
catch (e) {
}
}
Maybe by reading the code you can see what I'm trying to do. When it
executes "alert(''+cont. nodeName);", it displays "for". I need to display
"textarea" because that's what the label is associated with. If anyone can
help I'd appreciate it.