ignorant question

Discussion in 'Javascript' started by mammothman42@hotmail.com, Oct 2, 2004.

  1. Guest

    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
    , Oct 2, 2004
    #1
    1. Advertising

  2. Randy Webb Guest

    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
    Randy Webb, Oct 2, 2004
    #2
    1. Advertising

  3. Fred Oz Guest

    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
    Fred Oz, Oct 2, 2004
    #3
  4. Guest

    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
    , Oct 2, 2004
    #4
  5. Ryan Stewart Guest

    <> wrote in message
    news:...
    > 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(...)
    Ryan Stewart, Oct 2, 2004
    #5
  6. McKirahan Guest

    <> wrote in message
    news:...
    > 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>
    McKirahan, Oct 2, 2004
    #6
  7. Guest

    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
    , Oct 2, 2004
    #7
  8. Ryan Stewart Guest

    <> wrote in message
    news:...
    > 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-Level-2-Core-20001113/
    Ryan Stewart, Oct 2, 2004
    #8
  9. Guest

    perfect! thanks for the help guys.

    cheers
    dave
    , Oct 2, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dan m

    painfully ignorant but frustrating

    dan m, Feb 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    300
    Alvin Bruney [MVP]
    Mar 2, 2004
  2. Mike
    Replies:
    4
    Views:
    355
  3. Rut

    xml ignorant

    Rut, Nov 19, 2004, in forum: XML
    Replies:
    3
    Views:
    420
    cr88192
    Nov 20, 2004
  4. David Lozzi
    Replies:
    4
    Views:
    385
    David Lozzi
    Jul 26, 2007
  5. Debo
    Replies:
    8
    Views:
    110
Loading...

Share This Page