codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  help: location of an element within a collection  ereza at 12:33 on Thursday, September 02, 2004
 

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


  Re: help: location of an element within a collection  Yusairi at 17:22 on Thursday, September 02, 2004
 

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
Yusairi: site expert
http://www.codetoad.com


  Re: help: location of an element within a collection  ereza at 02:54 on Friday, July 15, 2005
 

a zillion years later - thanks a lot
:))

  Re: help: location of an element within a collection  Yusairi at 10:33 on Friday, July 15, 2005
 

:)
Yusairi: site expert
http://www.codetoad.com









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
• C++
• Re: refresh parent after closing pop up window
• Dynamic Insertion
• Date and Time function around the world???
• Significant Factors
• Perl array access
• Re: huffman encoding and decoding in C++...
• Perl One Liner: Replace {(
• Re: html including php, accessing the functions


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009