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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.