ignorant question

M

mammothman42

hi

sorry new to jscript (woops! javascript) and feeling stupid, checked
the faq and google to no avail. i've got a <td> with some text in it
that i wanted to chage, so i put this in it:

<span id="value">some text</span>

But this didn't work:
document.getElementByID('value').innerText=value;

any ideas? also, where can i find a reference so if i have, say, a
<span>, i can find all the properties and methods i can apply to it?
i've checked DOM references, but couldn't find what i needed.
cheers
dave
 
R

Randy Webb

hi

sorry new to jscript (woops! javascript) and feeling stupid, checked
the faq and google to no avail. i've got a <td> with some text in it
that i wanted to chage, so i put this in it:

<span id="value">some text</span>

But this didn't work:
document.getElementByID('value').innerText=value;

Because you are trying to set its value to a variable named value. Also,
innerText is IE only. See below.
any ideas? also, where can i find a reference so if i have, say, a
<span>, i can find all the properties and methods i can apply to it?
i've checked DOM references, but couldn't find what i needed.

http://jibbering.com/faq/#FAQ4_15 and its DynWrite is what you are
hunting. It applies for SPAN tags as well as a DIV tag.

You could also give the TD tag an ID and DynWrite to it as well,
nullifying the need for a span inside the TD.
 
F

Fred Oz

sorry new to jscript (woops! javascript) and feeling stupid, checked
the faq and google to no avail. i've got a <td> with some text in it
that i wanted to chage, so i put this in it:
[snip]

You can also use DOM methods to create a new text node and replace the
text node inside the TD. There are lots of examples in this news group
of how to do it.

Cheers, Fred
 
M

mammothman42

interesting. well i've tried this:

<td align="center" id="timeLength">some text</td>

and in js:

document.getElementByID('timeLength').firstChild.nodeValue="some other
text";

but it spits out an error. any ideas?

cheers
dave
 
R

Ryan Stewart

interesting. well i've tried this:

<td align="center" id="timeLength">some text</td>

and in js:

document.getElementByID('timeLength').firstChild.nodeValue="some other
text";

but it spits out an error. any ideas?
Yes: getElementById(...)
 
M

McKirahan

hi

sorry new to jscript (woops! javascript) and feeling stupid, checked
the faq and google to no avail. i've got a <td> with some text in it
that i wanted to chage, so i put this in it:

<span id="value">some text</span>

But this didn't work:
document.getElementByID('value').innerText=value;

any ideas? also, where can i find a reference so if i have, say, a
<span>, i can find all the properties and methods i can apply to it?
i've checked DOM references, but couldn't find what i needed.
cheers
dave

JavaScript is case sensitive: getElementById not getElementByID

<html>
<head>
<title>changetd.htm</title>
</head>
<body>
<table border="1">
<tr>
<td id="value">some text</span></td>
</tr>
</table>
<script type="text/javascript">
document.getElementById("value").innerText = "some other text";
</script>
</body>
</html>
 
M

mammothman42

LOL i was looking at your answers for a while before i finally spotted
the small "d". regarding my other question again, does anyone know
where i can find a good complete online references to DOM methods and
attributes, so i can find things like "innerText", getChildNode, etc
for myself?

cheers
dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top