2009/3/11 laurin1 <keithda...@solidtechservice.com>:
>
> Why does Prototype through and error when trying to disable an img? It
> says that object does not support property or method. However, I can
> enable and disable the img element via HTML without a problem.
> >
>

Here is an updated demo for something I wrote to help someone with a
select toggling divs. Amended to include img tags.

Make sure you have set the display:none style inline.

<html>
<head>
  <script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js";></script>
  <script type="text/javascript">
function selectChanged(ev)
        {
        var s_ShowID=$F('select1');
        var a_Divs =
                {
                'a' : 'diva divb',
                'c' : 'divc divd',
                'me' : 'divrichard divquadling',
                'img' : 'imga imgb imgc imgd imge imgf imgg'
                };

        $A($w(a_Divs[s_ShowID]))
                .each(function(s_Div){
                        $(s_Div)
                                .show();
                        });
        $H(a_Divs)
                .each(function(set){
                        if (set.key != s_ShowID)
                                {
                                $A($w(set.value))
                                        .each(function(s_Div){
                                                $(s_Div)
                                                        .hide();
                                                });
                                }
                });
        }

document.observe('dom:loaded', function(){
        $('select1')
                .observe('change',selectChanged)
                .observe('keyup',selectChanged)
                .observe('click',selectChanged);
});
</script>
<title>Demo</title>
</head>
<body>
<div style="width:300px;">
        <div style="float:right;" id="divcontainer">
                <img id="imga" 
src="http://www.prototypejs.org/images/logo-home.gif";
style="display:none;">
                <div id="diva"
style="background-color:red;width:100px;height:100px;display:none;"></div>
                <img id="imgb" 
src="http://www.prototypejs.org/images/logo-home.gif";
style="display:none;">
                <div id="divb"
style="background-color:green;width:100px;height:100px;display:none;">default
showing</div>
                <img id="imgc" 
src="http://www.prototypejs.org/images/logo-home.gif";
style="display:none;">
                <div id="divc"
style="background-color:yellow;width:100px;height:100px;display:none;"></div>
                <img id="imgd" 
src="http://www.prototypejs.org/images/logo-home.gif";
style="display:none;">
                <div id="divd"
style="background-color:blue;width:100px;height:100px;display:none;"></div>
                <img id="imge" 
src="http://www.prototypejs.org/images/logo-home.gif";
style="display:none;">
                <div id="divrichard"
style="background-color:blue;width:100px;height:100px;display:none;">Richard</div>
                <img id="imgf" 
src="http://www.prototypejs.org/images/logo-home.gif";
style="display:none;">
                <div id="divquadling"
style="background-color:blue;width:100px;height:100px;display:none;">Quadling</div>
                <img id="imgg" 
src="http://www.prototypejs.org/images/logo-home.gif";
style="display:none;">
        </div>
        <div>
                <select id="select1">
                        <option value="a">A and B</option>
                        <option value="c">C and D</option>
                        <option value="me">Richard Quadling</option>
                        <option value="img">Show images</option>
                </select>
        </div>
</div>
</body>
</html>


-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to