Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change bgcolor of a cell in jvscript

Status
Not open for further replies.

split27

Technical User
Nov 8, 2001
15
0
0
FR
Hi,
I fill a table from my database and I would like to change the background color of the row you click on.
I know the property style.color maybe I could use that and change only the color of the text in the cells...

Do you have some good ideas to do that ?

I use IE 4.
I'd like to do it with javascript.
I hope it helps you.
--
X-) Split.
 
you could use the property style.backgroundColor.

Cheers,

Tom
 
Thanks for trying to help me.
I've found the property : style.background

But how to change it on click ?

Here is an example how I fill my table :

Sub FillTableFromRecord()
myrecordset.MoveFirst
Do Until myrecordset.EOF
document.write(&quot;<TR>&quot;)
document.write(&quot;<TD>&quot; & rsProjet.Fields(&quot;Name&quot;).value & &quot;</TD>&quot;)
document.write(&quot;<TD>&quot; & rsProjet.Fields(&quot;FirstName&quot;).value & &quot;</TD>&quot;)
document.write(&quot;<TD>&quot; & rsProjet.Fields(&quot;Birthday&quot;).value & &quot;</TD>&quot;)
document.write(&quot;</TR>&quot;)
rsProjet.MoveNext
Loop
End Sub


I tried document.write(&quot;<TD OnClick='this.style.background=#0000FF'>&quot; & rsProjet.Fields(&quot;Nom&quot;).value & &quot;</TD>&quot;)
But it didn't work. I tried to add the OnClick expression in the <TR> but nothing happened...

What could I try now ?
I hope it will help you to help me...
I hope it helps you.
--
X-) Split.
 
Have you tried

<tr onclick=this.style.backgroundColor='#98fb98';>

this works for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top