Jump to content

Change cell background, FF ok IE no good ?!!


iPixel

Recommended Posts

basically i have a cell with a picture as its background, so i wrong this little javascript to flip it if the checkbox inside the cell is checked on. But for some reason it only works in Firefox not Internet Explorer.

 

The function call looks like so >>

 

<TD COLSPAN="2" VALIGN="middle" ALIGN="center" ID="meetandgreet" style=" background-image:url(SELECTED/meet.jpg); background-repeat: no-repeat;" NOWRAP><INPUT TYPE="checkbox" ID="meet" VALUE="Include Meet & Greet" onchange="flipimg('meetandgreet', 'meet', 'meetselected.jpg', 'meet.jpg')"></TD>

 

And here's my Javascript >>

 

//This script is used to flip over the backgrounds for the Meet & Greet
function flipimg(idcell, idfield, imgNameOn, imgNameOff) 
// idcell = ID of <TD> Cell, idfield = ID of the checkbox/radio button, imgNameOn imgNameOff = image names, extension included.
{
	if(document.getElementById(idfield).checked)
		{
			document.getElementById(idcell).style.background = "url(SELECTED/" + imgNameOn + ") no-repeat";
		}
	else
		{
			document.getElementById(idcell).style.background = "url(SELECTED/" + imgNameOff + ") no-repeat";
		}
}

 

This works like a charm in Firefox but in IE its completely dead. Any ideas why ?!

 

I've tried looking it up with google but some sites say it getElementById worx on IE and some say it doesnt and you should use document.all instead ?! and sometimes its vice a versa.

 

Thanks in advance for the help.

Link to comment
https://forums.phpfreaks.com/topic/98262-change-cell-background-ff-ok-ie-no-good/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.