473,397 Members | 1,972 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,397 software developers and data experts.

Workaround for document.getElementById("mydiv").style.display='no ne'

Hi,

I have an onchange method for a select box that goes something like
this (the select is in a form named aForm):

function page_on_change() {
pageElement = aForm.my_page_id;
aForm.nav_page_name.value =
pages[pageElement.options[ pageElement.selectedIndex ].value];
var si = pageElement.selectedIndex;
for ( i = 0 ; i < pages.size ; i++ ) {
document.getElementById("id_" + i).style.display='none';
}
document.getElementbyId("id_" + si).style.display='none';
}

IE fails on the statement:

document.getElementbyId("id_" + si).style.display='none';

and says it doesn't support this property.

What is the workaround?

Thanks.

Mar 16 '07 #1
4 70049
IE fails on the statement:
>
document.getElementbyId("id_" + si).style.display='none';
Capitalize 'By' in getElementById. Javascript is case-sensitive.

Mar 16 '07 #2
Thanks Walton,

Great catch.

Now a message popus up that says Object required.

I've eyeballed the source and confirmed that divs id_0,id_1 etc exist.
On Mar 16, 12:29 pm, "Walton" <jrhol...@gmail.comwrote:
IE fails on the statement:
document.getElementbyId("id_" + si).style.display='none';

Capitalize 'By' in getElementById. Javascript is case-sensitive.

Mar 16 '07 #3
Opps. I got it. Thanks.

Mar 16 '07 #4
gi*******************@yahoo.com wrote :
Thanks Walton,

Great catch.

Now a message popus up that says Object required.

You are not correctly accessing form elements.
I have an onchange method for a select box that goes something like
this (the select is in a form named aForm):

function page_on_change() {
pageElement = aForm.my_page_id;
aForm.nav_page_name.value =
pages[pageElement.options[ pageElement.selectedIndex ].value];
You must access the form element like this:

document.forms["aForm"]
and not like
aForm

Accessing Elements with the W3C DOM
http://developer.mozilla.org/en/docs...th_the_W3C_DOM

Referencing Forms and Form Controls by comp.lang.javascript newsgroup
FAQ notes
http://jibbering.com/faq/faq_notes/form_access.html

Referencing Forms and Form elements correctly, Javascript Best
Practices, by Matt Kruse
http://www.javascripttoolbox.com/bestpractices/#forms

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
Mar 17 '07 #5

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

Similar topics

2
by: Stewart | last post by:
Hi Experts. Please put the code sample below into an html document and take a look at in NN6+. One span should be shown while the other is hidden. Clicking the button should reverse this. ...
8
by: Chris Markle | last post by:
When JavaScript writes out a dialogue box (like when confirm() is called) the header or title of that dialogue box shows up as "JavaScript Application"... Can this title be changed so that maybe...
3
by: Erwin Moller | last post by:
Hi all, Situation: A (rather long) page that contains a lot of divs. Some are visible (display:inline) at a certain time, other not. The javascript is responsible for divs to be visible or...
2
by: Erwin Moller | last post by:
Hi group, I have this obscure problem that really needs to be fixed, but I am out of ideas. Because the original script is very big, I'll try to summarize its functionality. Setup: - many...
2
by: Jake Barnes | last post by:
Imagine I've this block of HTML: <p>Alex Schein Mailing List <input type="checkbox" name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"...
2
by: Jake Barnes | last post by:
Imagine I have these two lines of HTML: <p>Pick a list: (<a href="mcControlPanel.php" onClick="hideOrShowDivById('newMailList'); return false;">Create New List?</a>)</p> <form...
1
by: jelumalai | last post by:
I am using display:none with using Table. When show the onClick using javascript. Then it will show, again i will hide, content only hidden, but that table doesn't hide. <script> function...
10
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this...
2
by: dgourd | last post by:
I cant get the style.display property to work properly. I have this test html page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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
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,...

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.