innerHTML Method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sinister747
    New Member
    • Jul 2008
    • 13

    innerHTML Method

    Hi All,

    Can anybody tell me why the below doesn't work;

    [code=javascript]
    T_Price = 23;

    document.GetEle mentByID("store _price").innerH TML = T_Price.toFixed (2);
    [/code]

    If i try

    [code=javascript]
    document.GetEle mentByID("store _price").innerH TML = 'Mama Mia!';
    [/code]

    It works fine, all help appreciated!
  • Sinister747
    New Member
    • Jul 2008
    • 13

    #2
    Got this error fixed, anybody has this problem.. i forgot that javascript it case sensitive it should have been;

    Code:
    document.getElementById("store_price").innerHTML = T_Price.toFixed(2);

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      That's correct, of course, but I'm intrigued as to how the second line worked.

      Comment

      • Sinister747
        New Member
        • Jul 2008
        • 13

        #4
        Hi,

        Because when i copied and pasted the second line of the internet and into my code (from a innerHTML sample).

        But when i wrote it above i made the same mistake again of the case sensitive thingy..

        So the one above didn't work.. but the one i got of the internet did..

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          That explains it. I did think as much, but just making sure. Thanks.

          If you're new to JavaScript, the case-sensitivity problem is a common one, especially if you're used to using a language which is not so strict.

          Comment

          Working...