I have a table cell with a picture as its background, and a checkbox. Once the checkbox is selected, change the background.
Here is the cell
TD COLSPAN="2" VALIGN="middle" ALIGN="center" ID="meetandgreet" style=" background-image:url(SELECTED/meet.jpg); background-repeat: no-repeat;" NOWRAP%26gt;%26lt;INPUT TYPE="checkbox" ID="meet" VALUE="Include Meet %26amp; Greet" onchange="flipimg('meetandgreet', 'meet', 'meetselected.jpg', 'meet.jpg')"%26gt;%26lt;/TD%26gt;
Here is my JavaScript %26gt;
function flipimg(idcell, idfield, imgNameOn, imgNameOff)
{
if(document.getElementById(idfield)....
{
document.getElementById(idcell).st... = "url(SELECTED/" + imgNameOn + ") no-repeat";
}
else
{
document.getElementById(idcell).st... = "url(SELECTED/" + imgNameOff + ") no-repeat";
}
}
This works perfectly in FireFox for me but refuses to do anything in IE.
GetElementById working in FF but not in IE. WHY?download windows media player
IE has pathetic JavaScript support. You might want to check another method. Also try validating your script. In Firefox, get the Web Developer and Firebug addons and then you'll have some good JS debugging tools.
GetElementById working in FF but not in IE. WHY?internet explorer update internet explorer
I think you are making this a little more complicated than it needs to be.
I would change it to.
pass to function
flipimg(this)
function flipimg(idfield)
{
document.getElementById
("meetandgreet").style.backgroundImage
= ((idfield.Checked)? "url(SELECTED/meetselected") no-repeat" : "url(SELECTED/meet) no-repeat");
//needs to be all on one line don't remember if style is right
}
this is not the best forum for trying to show code.
No comments:
Post a Comment