473,486 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

document.all vs. document.getElementByID

I have the following drop-down in one of my pages. Note the use of
document.all in calling the ShowView function. This seems to work OK.

<select id='mySelect' style='font-size:120%; width:150px;'
onchange=ShowView(document.all['mySelect'].options[document.all['mySelect'].selectedIndex].value)>
<option value='PICKLEVEL1'>Pick Level 1</option>
<option value='PICKLEVEL2'>Pick Level 2</option>
<option value='PICKLEVEL3'>Pick Level 3</option>
<option value='CHECKPACK'>Check Pack</option>
<option value='SHIPPING'>Shipping</option>
</select>

But, if I modify it to use document.getElementByID, it generates a
syntax error. I've Googled around a bit and found examples that seem
to indicate that this should work.

onchange=ShowView(document.getElementByID('mySelec t').options[document.getElementByID('mySelect').selectedIndex].value)>

Can someone tell me what I'm doing wrong here?

Thanks.
Dec 12 '05 #1
2 5464


Martin wrote:

<select id='mySelect' style='font-size:120%; width:150px;'
onchange=ShowView(document.all['mySelect'].options[document.all['mySelect'].selectedIndex].value)>
Simply use
<select onchange="ShowView(this.options[this.selectedIndex].value);"
But, if I modify it to use document.getElementByID, it generates a
syntax error.


The method name is
document.getElementById
not document.getElementByID.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 12 '05 #2
Martin Honnen wrote:
Martin wrote:
But, if I modify it to use document.getElementByID, it generates a
syntax error.


The method name is
document.getElementById
not document.getElementByID.


Yep -

To the OP: Remember, JavaScript is a Case Sensitive language...

Dec 12 '05 #3

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

Similar topics

1
2684
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
12
3864
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
5433
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) {...
7
5960
by: PaulB | last post by:
Good Morning everybody, I'm trying to adapt a tutorial script that will handle the behaviour of an "Expanding/Contracting" site-navigation menu. The code that seems to handle the expansion and...
3
9239
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
1
36500
by: Andre Ranieri | last post by:
Hello, I'm trying to set up an ASP.NET 2.0 form where the user enters values in WebControls.TextBoxes for amount owing, interest and late fees and a JavaScript function totals the three values...
5
11111
by: garfy | last post by:
Hi i get this error in validation Line 22 column 6: document type does not allow element "title" here. <title>Seo Web Design Los Angeles - Web Design And Search Engine Optimization L ...
6
3354
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no...
4
2604
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
13
4913
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
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...
0
7319
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...
0
5430
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,...
0
4559
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...
0
1378
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 ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.