472,780 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 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 69972
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.