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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scripting row borders?

Status
Not open for further replies.

rubychyld

Programmer
Mar 22, 2001
76
US
I have created the row highlight script below, but the row borders do not change... probably because only TD cells have borders. So how would I get all the "child" TD cells based on the row my mouse is over?

Thanks in advance for being such a wonderful resource!
Liz

<script language=&quot;JavaScript&quot;>
var thisColor = element.style.color
var thisBgColor = element.style.backgroundColor
var thisBorderWidth = element.style.borderWidth
var thisBorderStyle = element.style.borderStyle
var thisBorderColor = element.style.borderColor
var thisfontWeight = element.style.fontWeight
function hig_lite()
{
element.style.color=&quot;#000066&quot;
element.style.backgroundColor=&quot;#FFFFFF&quot;
element.style.borderWidth=&quot;1px 0px 1px 0px&quot;
element.style.borderStyle=&quot;solid&quot;
element.style.borderColor=&quot;#000066 #FFFFFF #000066 #FFFFFF&quot;
element.style.fontWeight=&quot;bold&quot;
}
function low_lite()
{
element.style.color= thisColor
element.style.backgroundColor = thisBgColor
element.style.borderWidthvar = thisBorderWidth
element.style.borderStyle = thisBorderStyle
element.style.borderColor = thisBorderColor
element.style.fontWeight = thisfontWeight
}
</script> Catch the vigorous horse of your mind!
 
&quot;. So how would I get all the &quot;child&quot; TD cells based on the row my mouse is over? &quot;

To get an element's children (IE5.5 NS6) use something like.

//This function gets the cells from a row and returns them

function getCells(row){
// grab the cells - returns a collection
var cells = row.getElementsByTagName(&quot;td&quot;);
var numberOfCells = cells.length;
return cells;
}


You would call this from a row like this:
<tr onMouseOver=&quot;getCells(this)&quot;>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>


And to access the items in the collection i.e. the cells use:

var firstCellInRow = cells.item(0);

As well as ordinary array notation. The above is the same as

var firstCellInRowFromArray = cells.[0];

Note this is what is termed version 6 syntax, and will not work for such junk as NS4.x (but who cares anymore right)
;-)
 
Thank you for your help. This method makes sense!

Liz Catch the vigorous horse of your mind!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top