Would like to slide the a box up from two levels

I have the following code below that allows me to click on the register link and the register box will slide up, but I would like to place a third box below that one and have it slide up as well when you click on the forgot password link.  Is this possible?

$(document).ready(function() {
      $("#register-link").click(function() {
            $("#login").slideUp("fast");
            $("#mask").animate({height:$("#register").height()}, "fast");
            return false;
      });
      $("#login").click(function() {
            $("#login-area").slideDown("fast");
            $("#mask").animate({height:$("#login-area").height()}, "fast");
            return false;
      });
      $("#forgot").click(function() {
            $("#register").slideUp("fast");
            $("#mask").animate({height:$("#login-area").height()}, "fast");
            return false;
      });
});
LVL 1
pingeyegAsked:
Who is Participating?
 
anoyesCommented:
OK, well if you want the link to trigger the slide, then you should be using $('#forgot-link') instead of $('#forgot'), as forgot is the ID of your div and not the link.  And then you should be using $('#forgot').slideUp('fast') instead of $('#register').  So your last block of code should be

$("#forgot-link").click(function() {
            $("#forgot").slideUp("fast");
            $("#mask").animate({height:$("#login-area").height()}, "fast");
            return false;
});
0
 
pingeyegAuthor Commented:
Here is my HTML:

<div id="mask">
                              <div id="login" style="margin-bottom: 20px">
                                    Username <input type="text" name="username" class="input-box" />
                                    <div style="margin-top: 10px">
                                          Password <input type="password" name="password" class="input-box" />
                                    </div>
                                    <div style="margin-top: 10px; text-align: center">
                                          <input type="image" src="/images/loginbtn.png" />
                                          <input type="hidden" name="submitBtn" value="1" />
                                    </div>
                                    <div style="margin-top: 10px; text-align: center">
                                          <a id="register-link" href="">register</a> | <a id="forgot-link" href="">forgot password</a>
                                    </div>
                              </div>
                              <div id="register">
                                    Name <input type="text" name="name" class="input-box" />
                                          <div style="margin-top: 10px">
                                                Username <input type="text" name="username" class="input-box" />
                                          </div>
                                          <div style="margin-top: 10px">
                                                Password <input type="password" name="password" class="input-box" />
                                          </div>
                                          <div style="margin-top: 10px; text-align: center">
                                                <input type="image" src="/images/registerbtn.png" />
                                                <input type="hidden" name="registerBtn" value="1" />
                                          </div>
                                          <div style="margin-top: 10px; text-align: center">
                                                <a id="login" href="">login</a> | <a id="forgot-link" href="">forgot password</a>
                                          </div>
                              </div>
                              <div id="forgot">
                                    Email <input type="text" name="email" class="email" />
                                    <div style="margin: 10px 0 10px 0; text-align: center">or</div>
                                    Username <input type="text" name="email" class="username" />
                              </div>
                              </div>
0
 
pingeyegAuthor Commented:
Yeah, I didn't mean to past that the way it was.  I had changed it after I realized what was there.  Anway, that gives me a JQuery script error.  I wonder if I need a later version.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
anoyesCommented:
What's the error you get?  The latest JQ version is 1.3.2, so it probably couldn't hurt to upgrade to that if you don't have the latest (unless you're using the UI also - you'd have to upgrade that too).
0
 
pingeyegAuthor Commented:
It tells me that S is null.  This is on line 19 of jquery.min.js.  The way I have mine being called is:

<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">google.load("jquery", "1.3.2");</script>
0
 
anoyesCommented:
Hmm, ok.  Well, those minified scripts are impossible to debug, so try getting rid of - at least temporarily - the google loader and doing it directly with a script src of http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js, which is the uncompressed version from the Google CDN.  Secondly, do you have this page available somewhere where I could look at it?
0
 
pingeyegAuthor Commented:
Ok, using that I get an error once again.  The page in question is at http://forum.teenkidsradio.org.  Click on the forgot password link and the error will show.
0
 
RuurtjanCommented:
Hi,

First of all, an 'id' may only be used once, so i've replaced these with a class.
I don't know if this is anything near what you're looking for, but take a look at my code snippet.

It does what I want it to do in firefox, but chrome and IE seem to be having some dificulty with my code.
I'll try to fix this later, if this is what you want the script to do.

Regards,
Ruurtjan
<html>
	
	<head>
		<script type="text/javascript" src="jquery.js"></script>          
		<script type="text/javascript">
		$(document).ready(function() {
		      $(".login-link").click(function() {
		            $("#mask").animate({height:$("#login").height()}, "slow");
		            $("#login").slideDown("slow");
		            $("#register").slideUp("slow");
		            $("#forgot").slideUp("slow");
		            return false;
		      });
		      $(".register-link").click(function() {
		            $("#mask").animate({height:$("#register").height()}, "slow");
		            $("#register").slideDown("slow");
		            $("#login").slideUp("slow");
		            $("#forgot").slideUp("slow");
		            return false;
		      });
		      $(".forgot-link").click(function() {
		            $("#mask").animate({height:$("#forgot").height()}, "slow");
		            $("#forgot").slideDown("slow");
		            $("#register").slideUp("slow");
		            $("#login").slideUp("slow");
		            return false;
		      });
		      $("#register").hide();
		      $("#forgot").hide();
		});
		</script>
		<style>
			#login { background: lightblue; }
			#register { background: lightgreen; }
			#forgot { background: yellow; }
			#mask { background: black; }
		</style>
	</head>
	
	<body>
		<div id="mask">
          <div id="login">
                Username <input type="text" name="username" class="input-box" />
                <div style="margin-top: 10px">
                      Password <input type="password" name="password" class="input-box" />
                </div>
                <div style="margin-top: 10px; text-align: center">
                      <input type="image" src="/images/loginbtn.png" />
                      <input type="hidden" name="submitBtn" value="1" />
                </div>
                <div style="margin-top: 10px; text-align: center">
                      <a class="register-link" href="">register</a> | <a class="forgot-link" href="">forgot password</a>
                </div>
          </div>
          <div id="register">
                Name <input type="text" name="name" class="input-box" />
                      <div style="margin-top: 10px">
                            Username <input type="text" name="username" class="input-box" />
                      </div>
                      <div style="margin-top: 10px">
                            Password <input type="password" name="password" class="input-box" />
                      </div>
                      <div style="margin-top: 10px; text-align: center">
                            <input type="image" src="/images/registerbtn.png" />
                            <input type="hidden" name="registerBtn" value="1" />
                      </div>
                      <div style="margin-top: 10px; text-align: center">
                            <a class="login-link" href="">login</a> | <a class="forgot-link" href="">forgot password</a>
                      </div>
          </div>
          <div id="forgot">
                Email <input type="text" name="email" class="email" />
                <div style="margin: 10px 0 10px 0; text-align: center">or</div>
                Username <input type="text" name="email" class="username" />
	              <div style="margin-top: 10px; text-align: center">
	                    <a class="login-link" href="">login</a> | <a class="register-link" href="">register</a>
	              </div>
          </div>
          </div>
	</body>
	
</html>

Open in new window

0
 
anoyesCommented:
He does make a good point - IDs are only supposed to be used once.  The error, however, is occurring in the animate function of the JQ library.  Try getting rid of / commenting out the animation line in that forgot-link click function and see if the error goes away.
0
 
pingeyegAuthor Commented:
Well, now that I turned everything into a class, the layout is all way off.
0
 
anoyesCommented:
Yah, if your CSS is setup to use IDs to style those elements, then you'll need to adjust that too.  It's really the best way to go though, b/c since IDs should only be used once it can cause some real problems - especially in JS - if you start using an ID more than once.
0
 
pingeyegAuthor Commented:
Looks like I'm good to go now.  Thanks for all you guys' help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.