Forum Moderators: open

Message Too Old, No Replies

help: disabling DIVs does not disable sub-elements in FF

help: disabling DIVs and subelements (FF vs IE)

         

grimguin

2:05 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



This may be by design (i hope not). I am trying to disable (not make invisable) a layer and the elements on it. Think of this as part of a wizard. So I thought to try the disable property. I expect that when I disable the layer that the sub-elements will be disabled as well. This works as expected in IE (6-ish), but not Firefox (1.0.6). I can loop through the childNodes, but that's extra code and processing/error_catching/etc...

given HTML:
<input id='btnTglDiv' type='button' value='toggle div' onClick='btnTglDiv_onClick()'>
<DIV id='divAction'>
Name: task 1
<P>Desc: do this, this means that, etc...</p>
<input id='btn1' type='button' value='turn knob'>
<input id='btn2' type='button' value='open door'>
<div>

given JS:
<script type="text/javascript">
function btnTglDiv_onClick(){
alert("hi");
divAction=document.getElementById('divAction');
divAction.disabled=true;
alert("bye");
}
//
</script>

my JS back ground: I've been out of the JS world since 1.0, so I'm very impressed with all it can do now, and am updating my skills.

grimguin

grimguin

2:48 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



oops that function should read:
function btnTglDiv_onClick(){
document.getElementById ('divAction').disabled=true;
}

grimguin

3:13 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



one more clarification. I'm not using "<layer>" i'm using "div".

Bernard Marx

4:15 pm on Sep 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Disabling all descendant inputs of a DIV by setting disabled="true". I didn't know you could do that at all. I could be wrong, but that doesn't sound like standard behaviour to me. I think you may well have to loop through those childNodes.

grimguin

5:36 pm on Sep 27, 2005 (gmt 0)

10+ Year Member


oh, ok. Well that's how it works in java, delphi, vb, and c++. Just diable the 'panel/group' (simular to a div) and anything on it becomes disabled. I figured it would be the same. Its something you may want to consider for future implementations. That way every developer who wants to tdo this doesn't have to write the same darn function. I guess it comes down to an ease of use/development issue.

well have a great one,
cheers!

gg

grimguin

5:56 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



In an effort to proove my point I researched into the HTML, SGML, and CSS standards docs, and discovered that (big surprize <-sarcasm) you guys implemented it correctly. [humbled] The only SGML/HTML elements that are required to process the .disabled property are BUTTON, INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA.

FORM, DIV, and SPAN do not have a disabled property, nor should they propigate the disabled property to their children.

PS For everyone researching this from the IE mindset:
Don't get to dependant on non-standard technology. After a quick discussion with a few senior coder-types I realize that to automate this kind propigation might wrongly assume what the developer intends. So, eventhough IE propigates the disabled property to the children of FORMs, DIVs, and SPANs; it could produce undesired results... even ugly web pages rendering differently in different browsers. [gasp]

thanks for you quick response and patience

Bernard Marx

7:03 pm on Sep 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't get to dependant on non-standard technology

That's browser scripting (even design) rule No.1
- especially wrt IE.