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("className", "xxx") for IE
and
setAttribute("class", "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.getElementById(x +
'Lable').setAttribute("className", "dataLable_TextDisabled");
//netscape version
document.getElementById(x +
'Lable').setAttribute("class", "dataLable_TextDisabled");
}
}
}
}
} 2 5436
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("className", "xxx") for IE and setAttribute("class", "xxx") for Netscape
Do not use setAttribute for attribute which can be set in an other
specific way.
objRef.className = "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.length;
ElementIterator++)
{
var currentFormElement = currentForm.elements[ElementIterator];
if ((currentFormElement.disabled) && (currentFormElement.type !=
"button") && (currentFormElement.type != "submit"))
{
currentFormElement.className = "dataLable_TextDisabled";
};
}
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.getElementById(x + 'Lable').setAttribute("className", "dataLable_TextDisabled"); //netscape version document.getElementById(x + 'Lable').setAttribute("class", "dataLable_TextDisabled"); } } } } }
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
DU,
Thanks for the help...CES
"DU" <dr*******@hotWIPETHISmail.com> wrote in message
news:bq**********@news.eusc.inter.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("className", "xxx") for IE and setAttribute("class", "xxx") for Netscape
Do not use setAttribute for attribute which can be set in an other specific way.
objRef.className = "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.length; ElementIterator++) { var currentFormElement = currentForm.elements[ElementIterator]; if ((currentFormElement.disabled) && (currentFormElement.type != "button") && (currentFormElement.type != "submit")) { currentFormElement.className = "dataLable_TextDisabled"; }; }
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.getElementById(x + 'Lable').setAttribute("className", "dataLable_TextDisabled"); //netscape version document.getElementById(x + 'Lable').setAttribute("class", "dataLable_TextDisabled"); } } } } }
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
|
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,...
| |