473,666 Members | 2,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getAttribute("d isabled") not working in Netscape

CES
All,
I'm at a loss, the code below works in IE but not in Netscape and I'm
unskilled enough not to know why.

Essentially this code looks thru all of the form fields and if the input box
has a attribute of disabled="true" , attribute would only be present if the
field was disabled, then the label field's class is changed to a grayed out
color.

--- The first problem seems to be with the v==true statement, I've tried
every variation I can think of but v==true is the only one that works in IE.

--- The second problem is the way IE & Netscape/Opera uses different class
attribute statements, is their a way of using 1 setAttribute statement that
will work in IE and Netscape as apposed to:

setAttribute("c lassName", "xxx") for IE
and
setAttribute("c lass", "xxx") for Netscape

Any Help on these issues will be appreciated.

CES
function fDisableLable() {
for(var a = 0;a < document.forms. length;a++){
var fname = document.forms[a].name;
var f = document.forms[fname];
for(c = 0;c < f.length;c++){
var x = f.elements[c].id;
if(x!=""){
var v = f.elements[x].getAttribute(" disabled")
var t = f.elements[x].getAttribute(" type")

//This is where I'm having the problem
if((v==true)&&( t!="button")&&( t!="submit")){
//ie version
document.getEle mentById(x +
'Lable').setAtt ribute("classNa me", "dataLable_Text Disabled");
//netscape version
document.getEle mentById(x +
'Lable').setAtt ribute("class", "dataLable_Text Disabled");
}
}
}
}
}
Jul 20 '05 #1
2 5457
DU
CES wrote:
All,
I'm at a loss, the code below works in IE but not in Netscape and I'm
unskilled enough not to know why.

Essentially this code looks thru all of the form fields and if the input box
has a attribute of disabled="true" , attribute would only be present if the
field was disabled, then the label field's class is changed to a grayed out
color.

--- The first problem seems to be with the v==true statement, I've tried
every variation I can think of but v==true is the only one that works in IE.

--- The second problem is the way IE & Netscape/Opera uses different class
attribute statements, is their a way of using 1 setAttribute statement that
will work in IE and Netscape as apposed to:

setAttribute("c lassName", "xxx") for IE
and
setAttribute("c lass", "xxx") for Netscape
Do not use setAttribute for attribute which can be set in an other
specific way.

objRef.classNam e = "xxx";
will work in MSIE 6 for Windows, Opera 7, NS 7.x, Mozilla 1.x, K-meleon
0.8 and all other W3C DOM level 1 compliant browsers.

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-95362176

Same thing with the disabled attribute.

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-50886781

Any Help on these issues will be appreciated.

CES
function fDisableLable() {
for(var a = 0;a < document.forms. length;a++){
var fname = document.forms[a].name;
var f = document.forms[fname];
Why these 2 above instructions? Why not the simple, straightforward and
much more efficient (accessing forms' collection):

var currentForm = document.forms[a];
for(c = 0;c < f.length;c++){
var x = f.elements[c].id;
if(x!=""){
var v = f.elements[x].getAttribute(" disabled")

Here's how I would do this:

for(var ElementIterator = 0; ElementIterator < currentForm.len gth;
ElementIterator ++)
{
var currentFormElem ent = currentForm.ele ments[ElementIterator];
if ((currentFormEl ement.disabled) && (currentFormEle ment.type !=
"button") && (currentFormEle ment.type != "submit"))
{
currentFormElem ent.className = "dataLable_Text Disabled";
};
}

Not tested but I'm pretty sure this should work in all W3C DOM level 1
compliant browsers.

var t = f.elements[x].getAttribute(" type")

//This is where I'm having the problem
if((v==true)&&( t!="button")&&( t!="submit")){
//ie version
document.getEle mentById(x +
'Lable').setAtt ribute("classNa me", "dataLable_Text Disabled");
//netscape version
document.getEle mentById(x +
'Lable').setAtt ribute("class", "dataLable_Text Disabled");
}
}
}
}
}


One last coding recommendation. Absolutely avoid non-meaningful,
non-significant identifiers in your code. a, x, c, t, v in the absolute
(and even in the relative) mean nothing.. except letters.
Choosing non-intuitive, non-self-explanatory identifiers is bad for
debugging with softwares, it can not help you understand your code now
or later, it can not help others review your code, etc..

DU

Jul 20 '05 #2
CES
DU,
Thanks for the help...CES
"DU" <dr*******@hotW IPETHISmail.com > wrote in message
news:bq******** **@news.eusc.in ter.net...
CES wrote:
All,
I'm at a loss, the code below works in IE but not in Netscape and I'm
unskilled enough not to know why.

Essentially this code looks thru all of the form fields and if the input box has a attribute of disabled="true" , attribute would only be present if the field was disabled, then the label field's class is changed to a grayed out color.

--- The first problem seems to be with the v==true statement, I've tried
every variation I can think of but v==true is the only one that works in IE.
--- The second problem is the way IE & Netscape/Opera uses different class attribute statements, is their a way of using 1 setAttribute statement that will work in IE and Netscape as apposed to:

setAttribute("c lassName", "xxx") for IE
and
setAttribute("c lass", "xxx") for Netscape


Do not use setAttribute for attribute which can be set in an other
specific way.

objRef.classNam e = "xxx";
will work in MSIE 6 for Windows, Opera 7, NS 7.x, Mozilla 1.x, K-meleon
0.8 and all other W3C DOM level 1 compliant browsers.

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-95362176

Same thing with the disabled attribute.

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-50886781

Any Help on these issues will be appreciated.

CES
function fDisableLable() {
for(var a = 0;a < document.forms. length;a++){
var fname = document.forms[a].name;
var f = document.forms[fname];


Why these 2 above instructions? Why not the simple, straightforward and
much more efficient (accessing forms' collection):

var currentForm = document.forms[a];
for(c = 0;c < f.length;c++){
var x = f.elements[c].id;
if(x!=""){
var v = f.elements[x].getAttribute(" disabled")

Here's how I would do this:

for(var ElementIterator = 0; ElementIterator < currentForm.len gth;
ElementIterator ++)
{
var currentFormElem ent = currentForm.ele ments[ElementIterator];
if ((currentFormEl ement.disabled) && (currentFormEle ment.type !=
"button") && (currentFormEle ment.type != "submit"))
{
currentFormElem ent.className = "dataLable_Text Disabled";
};
}

Not tested but I'm pretty sure this should work in all W3C DOM level 1
compliant browsers.

var t = f.elements[x].getAttribute(" type")

//This is where I'm having the problem
if((v==true)&&( t!="button")&&( t!="submit")){
//ie version
document.getEle mentById(x +
'Lable').setAtt ribute("classNa me", "dataLable_Text Disabled");
//netscape version
document.getEle mentById(x +
'Lable').setAtt ribute("class", "dataLable_Text Disabled");
}
}
}
}
}


One last coding recommendation. Absolutely avoid non-meaningful,
non-significant identifiers in your code. a, x, c, t, v in the absolute
(and even in the relative) mean nothing.. except letters.
Choosing non-intuitive, non-self-explanatory identifiers is bad for
debugging with softwares, it can not help you understand your code now
or later, it can not help others review your code, etc..

DU

Jul 20 '05 #3

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

Similar topics

3
9257
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 work on FireFox or Netscape. What could be wrong? The function: function setActiveTab(tabNo) {
16
2271
by: rodchar | last post by:
hey all, you know when you log in to msdn and go to subscription downloads, the header of the page is fixed and the body of the page scrolls, is that done with frames? thanks, rodchar
2
1977
by: manojsingh | last post by:
hi, I am developing on a Payroll system and using Jsp/servlet technology. For this I have created a Employee Information Page which has three buttons Add Employee Information , Modifiy Employee Information and Delete Employee Information. There is a JavaScript function which executes on BODY tag's onload function. // -- <body onload="funAdd()" --// function funAdd() {
5
13348
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
8454
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...
0
8362
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
8878
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...
1
8560
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,...
1
6200
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
4200
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
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
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.