5 Replies - 2227 Views - Last Post: 19 April 2012 - 10:50 AM

#1 ellaandcodeysdaddy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 18
  • Joined: 21-March 12

Trying to change the Font color of an entire row

Posted 15 April 2012 - 09:06 AM

I'm trying to change the font color of an entire row. I can make the code change the background color - but not the font color.

thisCell.onmouseover=function(){with(tbl.rows(this.parentNode.rowIndex){style.backgroundColor='gray';style.color='red'}}
thisCell.onmouseout=function(){with(tbl.rows(this.parentNode.rowIndex)){style.backgroundColor='';style.color='#ffffff'}}



Is This A Good Question/Topic? 0
  • +

Replies To: Trying to change the Font color of an entire row

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: Trying to change the Font color of an entire row

Posted 15 April 2012 - 12:16 PM

check out the error console.
there is no sensible reason to use with() nowadays. I also wonder why you go all around with tbl.rows()? tbl.rows(this.parentNode.rowIndex) is the same as this.parentNode.

and, use indentation. it doesn’t slow down JS but makes it readable enourmously.
Was This Post Helpful? 0
  • +
  • -

#3 ellaandcodeysdaddy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 18
  • Joined: 21-March 12

Re: Trying to change the Font color of an entire row

Posted 19 April 2012 - 07:58 AM

1. I use indenting in my coding. It just didn't translate to my post.
2. What is a good alternative to with
3. Error console is no help because there is no error generated.
4. Thank you for the reponse.

View PostDormilich, on 15 April 2012 - 12:16 PM, said:

check out the error console.
there is no sensible reason to use with() nowadays. I also wonder why you go all around with tbl.rows()? tbl.rows(this.parentNode.rowIndex) is the same as this.parentNode.

and, use indentation. it doesn’t slow down JS but makes it readable enourmously.

Was This Post Helpful? 0
  • +
  • -

#4 ellaandcodeysdaddy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 18
  • Joined: 21-March 12

Re: Trying to change the Font color of an entire row

Posted 19 April 2012 - 08:11 AM

I found something that may be a hint but I still don't know why it's doing this.

If I remove

this.style.color="#ffffff"


from the script then the onmouseover commands work

This post has been edited by Dormilich: 19 April 2012 - 08:22 AM
Reason for edit:: removed unnecessary quote

Was This Post Helpful? 0
  • +
  • -

#5 ellaandcodeysdaddy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 18
  • Joined: 21-March 12

Re: Trying to change the Font color of an entire row

Posted 19 April 2012 - 08:42 AM

I just figured it out. It was because of the

this.style.color="#ffffff"
.

That was setting the color code on the cell where as the other line was updating the color on the parentNode. I changed it to

this.parentNode.style.color="#ffffff"
.

Code now works. I would still like to know an alternative to the with statement.

View Postellaandcodeysdaddy, on 19 April 2012 - 08:11 AM, said:

I found something that may be a hint but I still don't know why it's doing this.

If I remove

this.style.color="#ffffff"


from the script then the onmouseover commands work

Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: Trying to change the Font color of an entire row

Posted 19 April 2012 - 10:50 AM

View Postellaandcodeysdaddy, on 19 April 2012 - 05:42 PM, said:

I would still like to know an alternative to the with statement.

using the original code:
thisCell.onmouseover=function() {
    this.parentNode.style.cssText = "background-color: gray; color: red;";
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1