/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] onclick the table color will be changed

Hi all,

I am not very good in javascript and so I am here…?

I have total 2 images

Now the 2 images are arranged in 2 <td>s.Now if i click 1st img the table color will be changed and also if i click 2nd image the table color will be changed.

Is there any way to do it?Please suggest me.

Thanks in advance.

Luv…Raj.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorMar 08.2007 — Could be something like this:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;meta http-equiv="Content-Script-Type" content="txt/javascript"&gt;
&lt;script type="text/javascript"&gt;
function changeCol(col){
document.getElementById('mytab').style.backgroundColor=col;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table width="300" border="0" cellspacing="0" cellpadding="0" id="mytab"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="00.jpg" width="73" height="100" alt="" onclick="changeCol('#FF0000')"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="01.jpg" width="73" height="100" alt="" onclick="changeCol('#FFFF00')"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@raj_2006authorMar 09.2007 — hi

Its working a great man.Thanks mate for your contribution.

.......Luv....Raj
×

Success!

Help @raj_2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...