Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > ignorant question

Reply
Thread Tools

ignorant question

 
 
mammothman42@hotmail.com
Guest
Posts: n/a
 
      10-02-2004
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

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      10-02-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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.


--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
 
Reply With Quote
 
 
 
 
Fred Oz
Guest
Posts: n/a
 
      10-02-2004
(E-Mail Removed) wrote:

> 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
 
Reply With Quote
 
mammothman42@hotmail.com
Guest
Posts: n/a
 
      10-02-2004
interesting. well i've tried this:

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

and in js:

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

but it spits out an error. any ideas?

cheers
dave

 
Reply With Quote
 
Ryan Stewart
Guest
Posts: n/a
 
      10-02-2004
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> interesting. well i've tried this:
>
> <td align="center" id="timeLength">some text</td>
>
> and in js:
>
> document.getElementByID('timeLength').firstChild.n odeValue="some other
> text";
>
> but it spits out an error. any ideas?
>

Yes: getElementById(...)


 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      10-02-2004
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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>


 
Reply With Quote
 
mammothman42@hotmail.com
Guest
Posts: n/a
 
      10-02-2004
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

 
Reply With Quote
 
Ryan Stewart
Guest
Posts: n/a
 
      10-02-2004
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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
>

http://www.w3.org/TR/2000/REC-DOM-Le...Core-20001113/


 
Reply With Quote
 
mammothman42@hotmail.com
Guest
Posts: n/a
 
      10-02-2004
perfect! thanks for the help guys.

cheers
dave

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
semi-ignorant question salmobytes Digital Photography 6 03-20-2008 05:54 PM
very ignorant networking question - Reg NZ Computing 4 02-27-2008 02:08 AM
Ignorant question regarding includes Debo Perl Misc 8 05-27-2005 11:29 PM
Ignorant meta-document (from schema?) question Mike XML 4 11-03-2004 05:25 PM
Re: Ignorant me kpg MCSE 0 04-02-2004 12:50 AM



Advertisments