[Javascript] Check boxs and table row back ground colors
Mike Dougherty
mdougherty at pbp.com
Tue Apr 25 10:06:32 CDT 2006
If you're going to make a bold statement about strict validation, I will one-up that with the best
practice suggestion to not register javascript inline either. Also, you probably want to make the
method fire a function rather than directly manipulating object properties. Then that function
should probably only alter the className property.
maybe something like this:
HTML: <input ... onMethod="highlightrow( this );" caveat="inline example easier to type up">
Javascript:
function highlightrow( obj ){
loTD = obj.parentNode; /* reference the TD containing the element that fired the method */
loTR = loTD.parentNode; /* reference the TR */
if(obj.checked){
loTR.className += " highlighted"; /* add the 'highlighted' class to this element */
}
else {
loTR.className = loTR.className.replace(/\shighlighted/g,""); /* remove the class */
}
}
CSS:
tr { background-color: white; }
tr.highlighted { background-color: not-white; }
Note: that regexp is probably not 100% right (sorry)
On Tue, 25 Apr 2006 15:57:12 +1000
"Abyss - Information" <Info at Abyss.ws> wrote:
> the page is XHTML 1.1 strict compliant (which every page should be - *ducts from the objects
>that non compliant people throw*)
>
> <input id="chkbxID<%=rs("ID")%>" name="chkbxID" type="checkbox" value="<%=rs("ID")%>"
>onselect="this.style.background-color='#123456';" />
More information about the Javascript
mailing list