Need help using substringData()

Giganews Newsgroups
Subject: Need help using substringData()
Posted by:  Dudely (ab33…@gmail.com)
Date: Thu, 28 Jun 2007

I can't seem to get subStringData() to work.  Can someone tell me what
I'm doing wrong and how to fix it?

Sample minimal code below.  In case it's not obvious, foo() is meant
to be a generic function, capable of accepting any element with an id
that starts with the word "column", and followed by a number.  So,
"column1", "column13", etc.  The goal is to strip off the initial word
"column" and so be left with just the number as the resultant
substring.

For the record, I've spent many hours looking over the DOM model,
searching for examples, trying various things, etc.  I still don't see
what I'm doing wrong.

Thank you

<head>

<script>
function foo(elmnt)
{
elmnt.style.color='green';
var txt;
var tbl;

// length of the string "column" is 6
var end=elmnt.id.length-6;

// This one works
txt="<BR><h3>" + elmnt.id + " length=" + elmnt.id.length + "</h3>";
//document.write(txt);

// So why doesn't this one?
tbl=elmnt.id.substringData(6,end);
document.write(tbl);
}

</script>
</head>

<body>

<table><tr>
<td id="column1" onMouseOver="foo(this)" ><a href="#" >Text1</a></td>
<td id="column2" onMouseOver="foo(this)" ><a href="#" >Text2</a></td>
</tr></table>

</body>
</html>

Replies