473,785 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

Jul 20 '05 #1
2 9592
Hi,
Use getElementById instead of getElementByID. ...
(Note: Id not ID )
What a difference case makes!
Greg <ju******@green treesoftwaresys tems.com> wrote in message
news:TPP8b.3257 $Cu3.389@edtnps 84...
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.

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******@green treesoftwaresys tems.com> wrote in message
news:TPP8b.3257 $Cu3.389@edtnps 84...
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.



Jul 20 '05 #3

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

Similar topics

2
20948
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 when it's not hidden but I need to be able to make it hidden so I can use layers to show all when it finished drawing to make it smoother. This is how some other scripts are doing it that i've seen. So i've got it drawing a line and I need...
12
3944
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 both single quotes and no single quotes, but it doesn't work either way. What am I doing wrong? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById('weblogs').style.visibility='hidden';
4
5484
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) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs')
6
1516
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 the error that you see below. What is up? <html> <head> </head> <body>
3
2448
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: <div class="small" style="display: none" id="menu1_menu"> when the heading is clicked: <a href=.. onClick="expandDiv('menu1')">
21
8000
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 original statement is this (and note, when I add line above to it, that does not work): function uniqueValues(){
4
2667
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 but is a dead fish in FireFox. There is no support offered on the site where it came from. I'd really appreciate help with this as it will not only to get it working but to learn how it all works so I can add it to my repertoire. Thanks!
5
4439
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'); //works EBI3('myText'); //unexpected error
1
8567
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 Content Page/Master Page scenario - I've got the function inside the Content page, along with the all the items herein On each row, each of the in and out and total controls have a number associated with them, like:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.