|
|
hey people
perhaps anyone can help??
I have a <tr> and 5 <td> children
I'm standing (mouseover) on the third <td> and I want, with javascript, to get the location of this td, within the <td> collection.
I want to get the number 3.
is that possible??
thanks a lot in advanced!!
helpless erez
|
|
|
|
hi ereza,
this some code for you to try out. smile while testing
this code...
----------------------------------
<html>
<head>
<style>
.tdHighlight {background-color: #ffff99; font-weight:normal; cursor:hand}
.tdNormal {background-color: "#eeeeee"}
.tdHeader {background-color: "#ffffff"}
</style>
<script language="javascript">
function showInfoBox(name) {
var r='';
var rowObj=name.parentElement;
for(x=0; x<rowObj.childNodes.length;x++) {
r += '<b>' + rowObj.parentElement.childNodes[0].childNodes[x].innerText + '</b> ' + rowObj.childNodes[x].innerText + ', ';
}
rowObj.childNodes[0].className = 'tdHighlight';
rowObj.childNodes.className = 'tdHighlight';
rowObj.childNodes.className = 'tdHighlight';
buildInfoBox(r);
}
function showHighlight(name) {
var rowObj=name.parentElement;
rowObj.childNodes[0].className = 'tdHighlight';
rowObj.childNodes.className = 'tdHighlight';
rowObj.childNodes.className = 'tdHighlight';
}
function clearHighlight(row) {
document.all.mainTable.childNodes[0].childNodes[row].childNodes[0].className = 'tdNormal';
document.all.mainTable.childNodes[0].childNodes[row].childNodes.className = 'tdNormal';
document.all.mainTable.childNodes[0].childNodes[row].childNodes.className = 'tdNormal';
}
function clearInfoBox(row) {
infoBox.style.visibility = "hidden";
}
function buildInfoBox(text) {
document.all.infoBox.innerHTML = text;
infoBox.style.visibility = "visible";
}
</script>
</head>
<body>
<div id="infoBox"> </div><br>
<table id="mainTable" border="0" cellspacing="1" cellpadding="3">
<tr>
<td class="tdHeader">ID</td>
<td class="tdHeader">File Name</td>
<td class="tdHeader">Size</td>
</tr>
<tr>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(1)">117</td>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(1)">Default.aspx</td>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(1)">12K</td>
</tr>
<tr>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(2)">213</td>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(2)">Catalog.aspx</td>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(2)">23K</td>
</tr>
<tr>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(3)">624</td>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(3)">Report.aspx</td>
<td class="tdNormal" onClick="showInfoBox(this)" onMouseOver="showHighlight(this)" onMouseOut="clearHighlight(3)">51K</td>
</tr>
</table>
</body>
</html>
-------------------------------
"gain more knowledge at CodeToad.com"
yusairi
http://www.vss.com.my
|
|
|
|
|
|
a zillion years later - thanks a lot
:))
|
|
|
|
|
|
|
|
|
|
|
|