Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-29-2010, 03:26 PM   PM User | #1
SunnyHours
New to the CF scene

 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
SunnyHours is an unknown quantity at this point
Combining a function + command? More efficient?

Hi,

I'm building a side navigation for my website and I liked the Accordion effect in jQuery...I'm not really familiar with jQuery so I used Script.aculo.us instead...
So far so good it works, but I don't want it to stutter anymore and I want my 2 functions to be combined so I don't get the annoying click twice "bug"...
Code:
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">
	function detectStyleDisplay() {
		if (document.getElementById('a').style.display == "") {
			Effect.SlideUp('a');	
		}
		if (document.getElementById('b').style.display == "") {
			Effect.SlideUp('b');	
		}
		if (document.getElementById('c').style.display == "") {
			Effect.SlideUp('c');	
		}
		if (document.getElementById('d').style.display == "") {
			Effect.SlideUp('d');	
		}
	}
</script>
</head>
<body>
<div id="Products">
	<div id="Recessed">
		<h3 onclick="detectStyleDisplay(); Effect.BlindDown('a');">D</h3>
        <div id="a" style="display:none;">
        	<ul>
        		<li><a href="#">D</a></li>
            	<li><a href="#">D</a></li>
            	<li><a href="#">D</a></li>
            	<li><a href="#">D</a></li>
        	</ul>
		</div><!-- End of D Div -->
    	<h3 onclick="detectStyleDisplay(); Effect.BlindDown('b');>W</h3>
        <div id="b">
    		<ul>
        		<li><a href="#">W</a></li>
            	<li><a href="#">W</a></li>
            	<li><a href="#">W</a></li>
            	<li><a href="#">W</a></li>
        	</ul>
		</div><!-- End of W Div -->
        <h3 onclick="detectStyleDisplay(); Effect.BlindDown('c');>P</h3>
    	<div id="c">
        	<ul>
        		<li><a href="#">P</a></li>
            	<li><a href="#">P</a></li>
            	<li><a href="#">P</a></li>
            	<li><a href="#">P</a></li>
        	</ul>
		</div><!-- End of P Div -->
        <h3 onclick="detectStyleDisplay(); Effect.BlindDown('d')";>D</h3>
    	<div id="d">
        	<ul>
        		<li><a href="#">D</a></li>
            	<li><a href="#">D</a></li>
        	</ul>
		</div><!-- End of P Div -->
    </div><!-- End of Recessed Div -->
    
</div> <!-- End of Products Div -->
What I want is to combine the function detectStyleDisplay() and the "Effect.BlindDown('')" together...

I added this to the top of my function but it still doesn't work the way I want...
Code:
if (this.style.display == "none") {
   Effect.BlindDown('this');
}
Also what could I use instead of the hundreds of if statements I'm using? I'm trying to make this script a little bit more efficient...

Thanks!
Fred.
SunnyHours is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:43 PM.


Advertisement
Log in to turn off these ads.