473,657 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabling a select form element does not appear right in Internet Explorer

Hi,
I'm working on a JavaScript that is enabling / disabling a select
element according to whether a checkbox is selected or not.
This works fine in Firefox, but in Internet Explorer (v 6.0.2900) it
appears wierd:
When I disable the selevt element in IE, it continues to appear as
enabled (falsely) until I try changing it.

When I click on it, updates itself as grey as to indicate that it is
disabled.
This is wrong. I want it to appear as grey and disabled the moment it
is disabled via JS.
Is this a bug in IE, or should I do this different way (code below).

Is there perhaps some way to "update" the select element so that it
appears as disabled once I disable it with JS? (without having to click
on it to probe if it is disabled or not)

Here is the essential part of my code:

....
function disable(bool) {
document.getEle mentById('mySel ect).disabled = bool;
}
....
<input type="radio" name="y_n" onchange="javas cript:disable(t rue)">
Disable
<br>
<input type="radio" name="y_n" onchange="javas cript:disable(f alse)">
Enable
<br>
<select name="mySelect" id="mySelect">
<option value="test1">n ame 1</option>
<option value="test2">n ame 2</option>
<option value="test3">n ame 3</option>
<option value="test4">n ame 4</option>
</select>

Regards,
Per Magnus

Jun 19 '06 #1
1 2796
ke*********@hot mail.com wrote:
Hi,
I'm working on a JavaScript that is enabling / disabling a select
element according to whether a checkbox is selected or not.
This works fine in Firefox, but in Internet Explorer (v 6.0.2900) it
appears wierd:
Do not use onchange with a radio button, use onclick. IE doesn't fire
the event until the element loses focus (as per the W3C spec but very
confusing), Firefox fires it as soon as you click on the element.

Incidentally, use a checkbox and you only need one control.

[...]
Here is the essential part of my code:

...
function disable(bool) {
document.getEle mentById('mySel ect).disabled = bool;
}
...
<input type="radio" name="y_n" onchange="javas cript:disable(t rue)">
Disable
<br>
<input type="radio" name="y_n" onchange="javas cript:disable(f alse)">
Enable
<br>
You can ditch all the above and use:

<label for="cb01">Disa ble:<input type="checkbox" id="cb01"
onclick="
document.getEle mentById('mySel ect').disabled= this.checked;
"></label>
to get consistent behaviour in IE and Gecko browsers.
<select name="mySelect" id="mySelect">
<option value="test1">n ame 1</option>
<option value="test2">n ame 2</option>
<option value="test3">n ame 3</option>
<option value="test4">n ame 4</option>
</select>

--
Rob

Jun 20 '06 #2

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

Similar topics

1
10078
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list closes. The closing of the dropdown list can happen without changing the dropdown, hence the onchange event is not a sure way to determine that the dropdown list closed. Is this possible in Internet Explorer?
16
2047
by: Ralph Freshour | last post by:
How can I disable a button once it has been clicked? I want to prevent the user from clicking on it twice if they have a slow connection. Thanks...
2
1816
by: Sam Goffin | last post by:
Hi how can I resize my form borders in .NET (either VB or C#)? In one of my programs I want to extend the usual form size at one end (when the user clicks the "Details..." button), so I need the window to 'grow'. As I'm really new at .NET this is quite difficult for me.
1
1618
by: Howard Jess | last post by:
Apparently, form elements of type <input type="image" src="...> are not included in the form's elements collection. I don't understand why not; according to DOM2, all form control elements in the form are part of the elements collection. Further, this element doesn't appear in the (DOM0) document.images collection either; so it's really not well-accounted for.
4
7390
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird. Unfortunately, Internet Explorer doesn't quite work as expected -- it gives me an "invalid argument" error that I don't know how to fix. Here's the entire script, with form, annotated to explain what I'm doing and where the problem is occurring. I...
11
3015
by: Stefan Finzel | last post by:
Hi trying to remove one or all elements of select options fails for Pocket Internet Explorer. Is there a way to do this? if is_PIE { // this does not work on Pocket IE while (opt.length) { opt.remove(0); }
12
2251
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer. Select the TextEditor->Html->Validation tree option in the left-hand side of the
11
1685
by: Tim Streater | last post by:
Am I right in thinking that while I can disable a select, I can't disable the <option>s within the select? I think this is the case but would like to be sure. Thanks, -- tim
4
22132
by: Matthew Cox | last post by:
Hi, I've been searching the net all day today trying to figure out how one would accomplish what I originally thought would be a fairly straight forward and simple thing. The problem I'm trying to solve is that the designer would like to limit the total number of entires shown when you click on the drop-down arrow of a select box. I'm starting to think that this isn't possible. I've tried the following with no luck:
0
8302
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
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
7314
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
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();...
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.