holdencaulfield
12-08-2006, 10:42 AM
Hi everyone. This is my first post to this forum, so thank you all for taking the time to read my question. I've spent quite a bit of time researching this, but I haven't had any luck. I'm mostly a PHP guy, but Javascript is definitely on my "list" to study... but I'm in a bit of a pinch with this problem.
I am using Scriptaculous effects to blindup and blind down divs on the side of a page. It works perfectly fine when I only have two divs to switch between.
It currently works like this:
<a href="#" onClick="Effect.BlindUp('help');Effect.BlindDown('discussionread', {delay: .5}); return false;"><img src="images/discussion.png" border="0" /></a>
<a href="#" onClick="Effect.BlindUp('discussionread',{duration:1});Effect.BlindDown('help', {delay: 1});return false;"><img src="images/help.png" border="0" /></a>
I soon realized this will be more difficult for the javascript novice to have more than two links and two divs. As you can see in the above code, I have hard code what to BlindUp in my link. (Obviously if there are only two divs to choose from and the user clicks a link, then we must blind up the other div to reveal the desired div.)
In some tests, I've found that it is possible to use a variable name instead of a div name for the blind up.
To test this, I set the variable "currentdiv" like this:
<script language="JavaScript" type="text/javascript">
var currentdiv = "discussionread";
</script>
Then, I altered my links and added "currentdiv" as the blind up for my second link.
<a href="#" onClick="Effect.BlindUp('help');Effect.BlindDown('discussionread', {delay: .5}); return false;"><img src="images/discussion.png" border="0" /></a>
<a href="#" onClick="Effect.BlindUp(currentdiv,{duration:1});Effect.BlindDown('help', {delay: 1}); return false;"><img src="images/help.png" border="0" /></a>
It works - but in this case, it's not that much different than hard coding "discussionread" instead of my variable "currentdiv."
If I can find a way to set the variable "currentdiv" to whatever link is clicked, then theoretically I should be able to have all the links I want - because if the BlindUp is "currentdiv" then whatever is currently displayed will blind up and the desired link will blind down.
I appreciate you taking the time to look at my problem. Unfortunately I've not been able to find much help elsewhere on the web. I'm not sure if this question is too "noobish" or if my logic is so screwed up that people don't know where to begin.
At any rate, if you can provide some insight and push me in the right direction, I would be very grateful.
Thanks!
I am using Scriptaculous effects to blindup and blind down divs on the side of a page. It works perfectly fine when I only have two divs to switch between.
It currently works like this:
<a href="#" onClick="Effect.BlindUp('help');Effect.BlindDown('discussionread', {delay: .5}); return false;"><img src="images/discussion.png" border="0" /></a>
<a href="#" onClick="Effect.BlindUp('discussionread',{duration:1});Effect.BlindDown('help', {delay: 1});return false;"><img src="images/help.png" border="0" /></a>
I soon realized this will be more difficult for the javascript novice to have more than two links and two divs. As you can see in the above code, I have hard code what to BlindUp in my link. (Obviously if there are only two divs to choose from and the user clicks a link, then we must blind up the other div to reveal the desired div.)
In some tests, I've found that it is possible to use a variable name instead of a div name for the blind up.
To test this, I set the variable "currentdiv" like this:
<script language="JavaScript" type="text/javascript">
var currentdiv = "discussionread";
</script>
Then, I altered my links and added "currentdiv" as the blind up for my second link.
<a href="#" onClick="Effect.BlindUp('help');Effect.BlindDown('discussionread', {delay: .5}); return false;"><img src="images/discussion.png" border="0" /></a>
<a href="#" onClick="Effect.BlindUp(currentdiv,{duration:1});Effect.BlindDown('help', {delay: 1}); return false;"><img src="images/help.png" border="0" /></a>
It works - but in this case, it's not that much different than hard coding "discussionread" instead of my variable "currentdiv."
If I can find a way to set the variable "currentdiv" to whatever link is clicked, then theoretically I should be able to have all the links I want - because if the BlindUp is "currentdiv" then whatever is currently displayed will blind up and the desired link will blind down.
I appreciate you taking the time to look at my problem. Unfortunately I've not been able to find much help elsewhere on the web. I'm not sure if this question is too "noobish" or if my logic is so screwed up that people don't know where to begin.
At any rate, if you can provide some insight and push me in the right direction, I would be very grateful.
Thanks!