BDT
05-06-2003, 06:30 PM
I have a button that is superimposed on multiple images using a document.write statement in a loop. It works just fine, but I want to add a mouseover image. The following code is what I started with before I tried to add the mouseover:
document.write('<a href="#" id="button' +
i + '" onClick="switchcolor(this)"><img style="position:absolute; left:60px; top:50px; width:25px; height:25px"' + ' src="round_up_green.gif" border=0><a/>');
Is there a straitforward way to add a simple mouseover to this? Here is the general idea of what I want, but, of course, this didn't work:
document.write('<a href="#" id="button' +
i + '" onMouseOver="document.images[this].src=round_up_red.gif" onClick="switchcolor(this)"><img style="position:absolute; left:60px; top:50px; width:25px; height:25px"' +
' src="round_up_green.gif" border=0><a/>');
Unfortunatly, I can't just specify the images[] or elementId since they are different for each place the mouseover image appears. I know that I can do a workaround by calling a new function to do the mouseover image, but it doesn't seem this should be necessary. I imagine that I would also have to do some pretty complicated logic to detect which elementId I'm dealing with and then to correctly associate it with the proper images[]. Anyway, I appreciate any ideas that people may have to add a working onMouseOver parameter to the document.write statement.
thanks, BDT
document.write('<a href="#" id="button' +
i + '" onClick="switchcolor(this)"><img style="position:absolute; left:60px; top:50px; width:25px; height:25px"' + ' src="round_up_green.gif" border=0><a/>');
Is there a straitforward way to add a simple mouseover to this? Here is the general idea of what I want, but, of course, this didn't work:
document.write('<a href="#" id="button' +
i + '" onMouseOver="document.images[this].src=round_up_red.gif" onClick="switchcolor(this)"><img style="position:absolute; left:60px; top:50px; width:25px; height:25px"' +
' src="round_up_green.gif" border=0><a/>');
Unfortunatly, I can't just specify the images[] or elementId since they are different for each place the mouseover image appears. I know that I can do a workaround by calling a new function to do the mouseover image, but it doesn't seem this should be necessary. I imagine that I would also have to do some pretty complicated logic to detect which elementId I'm dealing with and then to correctly associate it with the proper images[]. Anyway, I appreciate any ideas that people may have to add a working onMouseOver parameter to the document.write statement.
thanks, BDT