ignorant question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mammothman42@hotmail.com

    ignorant question

    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">som e text</span>

    But this didn't work:
    document.getEle mentByID('value ').innerText=va lue;

    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

  • Randy Webb

    #2
    Re: ignorant question

    mammothman42@ho tmail.com wrote:[color=blue]
    > 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">som e text</span>
    >
    > But this didn't work:
    > document.getEle mentByID('value ').innerText=va lue;[/color]

    Because you are trying to set its value to a variable named value. Also,
    innerText is IE only. See below.
    [color=blue]
    > 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.[/color]

    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.javas cript FAQ - http://jibbering.com/faq

    Comment

    • Fred Oz

      #3
      Re: ignorant question

      mammothman42@ho tmail.com wrote:
      [color=blue]
      > 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:[/color]
      [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

      Comment

      • mammothman42@hotmail.com

        #4
        Re: ignorant question

        interesting. well i've tried this:

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

        and in js:

        document.getEle mentByID('timeL ength').firstCh ild.nodeValue=" some other
        text";

        but it spits out an error. any ideas?

        cheers
        dave

        Comment

        • Ryan Stewart

          #5
          Re: ignorant question

          <mammothman42@h otmail.com> wrote in message
          news:1096683210 .075540.165620@ k26g2000oda.goo glegroups.com.. .[color=blue]
          > interesting. well i've tried this:
          >
          > <td align="center" id="timeLength" >some text</td>
          >
          > and in js:
          >
          > document.getEle mentByID('timeL ength').firstCh ild.nodeValue=" some other
          > text";
          >
          > but it spits out an error. any ideas?
          >[/color]
          Yes: getElementById( ...)


          Comment

          • McKirahan

            #6
            Re: ignorant question

            <mammothman42@h otmail.com> wrote in message
            news:1096677443 .471688.53870@k 17g2000odb.goog legroups.com...[color=blue]
            > 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">som e text</span>
            >
            > But this didn't work:
            > document.getEle mentByID('value ').innerText=va lue;
            >
            > 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
            >[/color]

            JavaScript is case sensitive: getElementById not getElementByID

            <html>
            <head>
            <title>changetd .htm</title>
            </head>
            <body>
            <table border="1">
            <tr>
            <td id="value">som e text</span></td>
            </tr>
            </table>
            <script type="text/javascript">
            document.getEle mentById("value ").innerTex t = "some other text";
            </script>
            </body>
            </html>


            Comment

            • mammothman42@hotmail.com

              #7
              Re: ignorant question

              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

              Comment

              • Fred Oz

                #8
                Re: ignorant question

                mammothman42@ho tmail.com wrote:[color=blue]
                > 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
                >[/color]


                Appart from the FAQ for this news group, you can try at Mozilla:



                They have links to many useful sites (including W3C specs). The Mozilla
                DOM spec is very handy, but it's focuses on Mozilla (of course):



                Wherever they say "DOM level 0", it is not part of the spec but it is
                supported as legacy from older browsers.

                Have fun - Fred.

                Comment

                • Ryan Stewart

                  #9
                  Re: ignorant question

                  <mammothman42@h otmail.com> wrote in message
                  news:1096687113 .387680.315010@ k26g2000oda.goo glegroups.com.. .[color=blue]
                  > 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
                  >[/color]



                  Comment

                  • mammothman42@hotmail.com

                    #10
                    Re: ignorant question

                    perfect! thanks for the help guys.

                    cheers
                    dave

                    Comment

                    Working...