getElementById errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg

    getElementById errors

    I'm trying to understand getElementByID a bit better.

    When I try the following...

    if (parseFloat(doc ument.getElemen tByID('Quantity Made').value) > 0) {
    alert('it seems to exist');
    }

    (the text field QuantityMade holds a value of 17)

    I get an error saying the Object doesn't support this property or method.

    so I pare it down to this...

    if (document.getEl ementByID('Quan tityMade').valu e > 0) {
    alert('it seems to exist');
    }

    and get the same error

    So I try this...

    alert(document. getElementByID( 'QuantityMade') .value);

    and get the same error

    is this not a valid way to get the value of a text field when only its
    ID is known?? Is there a better strategy for getting and setting this
    value from anywhere in a page???

    Thanks.

  • Chris Crandell

    #2
    Re: getElementById errors

    Hi,
    Use getElementById instead of getElementByID. ...
    (Note: Id not ID )
    What a difference case makes!


    Greg <junkmail@green treesoftwaresys tems.com> wrote in message
    news:TPP8b.3257 $Cu3.389@edtnps 84...[color=blue]
    > I'm trying to understand getElementByID a bit better.
    >
    > When I try the following...
    >
    > if (parseFloat(doc ument.getElemen tByID('Quantity Made').value) > 0) {
    > alert('it seems to exist');
    > }
    >
    > (the text field QuantityMade holds a value of 17)
    >
    > I get an error saying the Object doesn't support this property or method.
    >
    > so I pare it down to this...
    >
    > if (document.getEl ementByID('Quan tityMade').valu e > 0) {
    > alert('it seems to exist');
    > }
    >
    > and get the same error
    >
    > So I try this...
    >
    > alert(document. getElementByID( 'QuantityMade') .value);
    >
    > and get the same error
    >
    > is this not a valid way to get the value of a text field when only its
    > ID is known?? Is there a better strategy for getting and setting this
    > value from anywhere in a page???
    >
    > Thanks.
    >[/color]


    Comment

    • Greg

      #3
      Re: getElementById errors

      WOW I feel like such a fool.

      Thanks Chris, I really needed that. (And of course it works fine now :-) )

      Greg.

      Chris Crandell wrote:[color=blue]
      > Hi,
      > Use getElementById instead of getElementByID. ...
      > (Note: Id not ID )
      > What a difference case makes!
      >
      >
      > Greg <junkmail@green treesoftwaresys tems.com> wrote in message
      > news:TPP8b.3257 $Cu3.389@edtnps 84...
      >[color=green]
      >>I'm trying to understand getElementByID a bit better.
      >>
      >>When I try the following...
      >>
      >>if (parseFloat(doc ument.getElemen tByID('Quantity Made').value) > 0) {
      >>alert('it seems to exist');
      >>}
      >>
      >>(the text field QuantityMade holds a value of 17)
      >>
      >>I get an error saying the Object doesn't support this property or method.
      >>
      >>so I pare it down to this...
      >>
      >>if (document.getEl ementByID('Quan tityMade').valu e > 0) {
      >>alert('it seems to exist');
      >>}
      >>
      >>and get the same error
      >>
      >>So I try this...
      >>
      >>alert(documen t.getElementByI D('QuantityMade ').value);
      >>
      >>and get the same error
      >>
      >>is this not a valid way to get the value of a text field when only its
      >>ID is known?? Is there a better strategy for getting and setting this
      >>value from anywhere in a page???
      >>
      >>Thanks.
      >>[/color]
      >
      >
      >[/color]

      Comment

      Working...