Click to See Complete Forum and Search --> : Question about accessing inline style...
I wanna change the background color of my tr to white, why might this not be working:
FUNCTION colorCng(e){
var color = "White";
document.myForm.getElementById(e.id).style.backgroundColor = color;
}
<tr id="3">
<td><input id="3" type="text" onClick="popUp(this);"></td>
</tr>
Jason
Zach Elfers
02-13-2003, 08:59 AM
FUNCTION colorCng(e){
var color = "White";
document.getElementById(e).style.backgroundColor = color;
}
<tr id="3">
<td><input id="3" type="text" onClick="popUp('3');"></td>
</tr>
gil davis
02-13-2003, 09:26 AM
An ID *must* start with a letter [A-Z,a-z], not a number.
thanks for the comment but I think you are wrong on this. Let me explain...
function popUp(e){
var color = "White";
var myTR = e.id;
document.getElementById(e.id).style.backgroundColor = color;
}
<tr id="3">
<td align="right"><input type="checkbox" id="#i#" name="#Name#" onClick="popUp(this);"></td>
</tr>
if #i# = 3 then the tr will turn white, although this isnt good code sense the checkbox's id is also 3. But anyway I hope you dont take offense on this observation.
Jason
gil davis
02-13-2003, 10:03 AM
From http://www.w3.org/TR/html4/types.html#type-name :
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
It may work in IE, but it isn't right.