473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

getElementById errors

I'm trying to understand getElementByID a bit better.

When I try the following...

if (parseFloat(document.getElementByID('QuantityMade' ).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.getElementByID('QuantityMade').value > 0) {
alert('it seems to exist');
}

and get the same error

So I try this...

alert(document.getElementByID('QuantityMade').valu e);

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.

Jul 20 '05 #1
2 9574
Hi,
Use getElementById instead of getElementByID....
(Note: Id not ID )
What a difference case makes!
Greg <ju******@greentreesoftwaresystems.com> wrote in message
news:TPP8b.3257$Cu3.389@edtnps84...
I'm trying to understand getElementByID a bit better.

When I try the following...

if (parseFloat(document.getElementByID('QuantityMade' ).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.getElementByID('QuantityMade').value > 0) {
alert('it seems to exist');
}

and get the same error

So I try this...

alert(document.getElementByID('QuantityMade').valu e);

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.

Jul 20 '05 #2
WOW I feel like such a fool.

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

Greg.

Chris Crandell wrote:
Hi,
Use getElementById instead of getElementByID....
(Note: Id not ID )
What a difference case makes!
Greg <ju******@greentreesoftwaresystems.com> wrote in message
news:TPP8b.3257$Cu3.389@edtnps84...
I'm trying to understand getElementByID a bit better.

When I try the following...

if (parseFloat(document.getElementByID('QuantityMade' ).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.getElementByID('QuantityMade').value > 0) {
alert('it seems to exist');
}

and get the same error

So I try this...

alert(document.getElementByID('QuantityMade').va lue);

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.



Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gary Mayor | last post by:
Hi, I'm back again. Basically i'm trying to draw a box over an image which is turning out to be a nightmare. The problem i'm getting at the moment is that i'm creating a line with <div which works...
12
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
6
by: lawrence | last post by:
I'm playing around with generating layer from a javascript. Strangely, the code below works fine in FireFox when I assign a color to 'color' but when I try to assign it to 'background-color' I get...
3
by: InvisibleMan | last post by:
Thanks in Advance for any help on this - its truely sending my head in loops... so I appreciate your efforts! okay, I have a javascript listed below that drops down submenus contained within:...
21
by: vadymus | last post by:
Hello, I need to compare 2 id names but not their values. For example: document.getElementById(i) == document.getElementById(j) these elements above seem to give error or do not work. My...
4
by: the other john | last post by:
I came across a third party script I want to learn how to configure as well as learn more dhtml in the doing. I'm not much of a JS guy yet but I'm working on it. This script works fine in IE6...
5
by: HopfZ | last post by:
I made two shortcut functions for document.getElementById as: function EBI2(id){return document.getElementById(id)}; var EBI3 = document.getElementById; But EBI3 don't work. EBI2('myText');...
1
by: Elmo Watson | last post by:
I've inherited a project that has quite a few Table rows - inside each cell, within the row are a couple of textboxes ("in" and "out"), along with a "total" label. Also - this is all within a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.