Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7633857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:00:14+00:00 2026-05-31T07:00:14+00:00

I know the question seems impossible. but I’m sure somebody can help me! I

  • 0

I know the question seems impossible. but I’m sure somebody can help me!

I have a div with options and a button, the users selects an option and clicks the ‘Next’ button.

What I want to happen is, the div with the options in, needs to animate to 0px height, load new content using ajax, then the div needs to re-animate to the new height of the contents…

So basically the div is shrinking, and then growing, but inbetween, the innerHtml is changing!

The code i have so far is:

function load_form( form_name ){
    var form_cont_elem = $("#form_container");
    var collapse_elem = $("#collapsable");

    // animate collapsable div to 0, callback ajax fetch
    collapse_elem.animate({height: "0px"}, 500, function(){

        $.get('/ajax/contact_form/' + form_name + '.html', function(data){
            // hide form container
            form_cont_elem.css({display: ""});
            // load data into form container
            form_cont_elem.html(data);
        });

    });

    // get new height of form
    var height_var = form_cont_elem.outerHeight();
    // remove display:none
    form_cont_elem.css({display: ""});
    // re-animate collapsable div to new height
    collapse_elem.animate({height: height_var}, 500);

}

the before the button click is:

<div id="collapsable">
    <div id="form_container">
        <p>What is the Nature of your Question?</p>
        <hr />
        <ul>
            <li><a>Quote</a></li>
            <li><a>Feedback</a></li>
            <li><a>Enquiry</a></li>
            <li><a>Complaint</a></li>
        </ul>
        <button class="blue">Next</button>
        <div class="clear"></div>
    </div>
</div>

the html after the button click is:

<div id="collapsable">
    <div id="form_container">
        <form method="post" action="/php/mailer.php">
            <fieldset>
                <input type="hidden" name="quote" />
                <label>Name</label>
                <input type="text" name="name" size="30" maxlength="30" />
                <label>Telephone Contact</label>
                <input type="text" name="telephone" size="30" maxlength="30" />
                <label>Email Address</label>
                <input type="text" name="email" size="30" maxlength="100" />
                <input class="orange" type="submit" name="submit" value="submit!" />
            </fieldset>
        </form>
    </div>
</div>

Now this javascript code works fine…

However, when I’m getting the NEW height of the #form_container, it returns the OLD height… now I’m assuming this is because the new information hasnt been drawn in the browser yet… So how do i overcome this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:00:16+00:00Added an answer on May 31, 2026 at 7:00 am

    I posted too early…

    What’s happening is, its fetching the ajax, but while its waiting for the ajax response, its running the code below! the:

    var height_var = form_cont_elem.outerHeight();
    form_cont_elem.css({display: ""});
    collapse_elem.animate({height: height_var}, 500);
    

    So I just put that code inside the ajax call like so

    var form_elem = $("#form_container");
    var coll_elem = $("#collapsable");
    
    coll_elem.animate({height: "0px"}, 500, function(){
        $.get('/ajax/contact_form/' + form_name.toLowerCase() + '.html', function(data){
            form_elem.css({display: "none"});
            form_elem.html(data);
    
            var height_var = form_elem.outerHeight();
            $("#collapsable").animate({height: height_var}, 500);
            form_elem.css({display: ""});
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question seems illogical, but I have to try, and I
OK, so I know this question seems really basic, but I can't find a
I know this seems like a repeat question, but i've read all the others
I know this maybe a basic question but I just can't seem to find
I know it's a simple question, but I can't seem to drag it out
This may seem as an almost impossible question, but I wish to know how
I know question seems little scamy but I couldn't find a better way to
Warning - I am very new to NHibernate. I know this question seems simple
I know the questions seems ambiguous, but I couldn't think of any other way
I know this question has been asked before numorous times but they seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.