Page 1 of 1

onclick Image

Posted: Wed Dec 22, 2010 5:43 am
by jisha
pickle | Please use [ syntax=php ], [ syntax=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Dear friends,
I want to use image other than the silver color. I tried ... Can u help me

Code: Select all

<html>
<head>
<script language="javascript">
function color(newC,oldC,button) {
newC.bgColor= "silver"
oldC.bgColor = ""
}

</script>
</head>
<body onload="color(c1,c2,name)">
<table background="gray.gif" height="20">
<tr>
<td width="49">
<td id="c1" width="50" height="5" onclick="color(c1,c2,this)"> </td>
<td id="c2" width="50" height="5" onclick="color(c2,c1,this)"> </td>
<td width="800"></td>
</tr>
</table>
</body>
</html>

pickle | Please use [ syntax=php ], [ syntax=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: onclick Image

Posted: Wed Dec 22, 2010 9:43 am
by pickle
Please explain more about what exactly you're trying to do. Run us through the process of what you want to happen.

Just looking at the code, you'll likely want to google for "Accessing DOM elements", "getElementById", and "change css with javascript".