#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171

    Close all other divs


    Hi;

    I have a page where you can click on "Book Now" buttons and it opens different booking forms.

    Now it is all working fine but when I click on a booking form , I want all other open book forms to close.

    How can I achieve that?



    I open book forms like this:
    Code:
    onclick="show_book_form(<?php echo $data['PID'];?>);"
    Code:
    function show_book_form(id)
    {
    	$('#' + id).show("blind")
    }
    The page

    Thanks
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,123
    Rep Power
    119
    This should do the trick:
    Code:
    function show_book_form(id)
    {
    $(".booking-container").hide();
    $('#' + id).show("blind")
    }
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by web_loone08
    This should do the trick:
    Code:
    function show_book_form(id)
    {
    $(".booking-container").hide();
    $('#' + id).show("blind")
    }
    Beautiful Many thanks
  6. #4
  7. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by web_loone08
    This should do the trick:
    Code:
    function show_book_form(id)
    {
    $(".booking-container").hide();
    $('#' + id).show("blind")
    }
    Hi;

    I am doing the same thing here but it doesn't work! Would you please tell me what I'm doing wrong?

    When you click on Skills Assessment for example, it should show the content under but it doesn't.
    Thanks
  8. #5
  9. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,123
    Rep Power
    119
    What..., like you had a space in an id attribute; like below?
    Code:
    <div id="Skills Assessment">
    
    </div>
    And you called it; like below?
    Code:
    <button onclick="show_book_form('Skills Assessment')">Book Now</button>
    If so, there is a reason for this; your not supposed to have white spaces, within the "id" attribute. So, that's probably why your getting errors.

    Here's some more reading; on above: https://developer.mozilla.org/en-US/..._attributes#id (read the "Usage note" >> list item number 2).
  10. #6
  11. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by web_loone08
    What..., like you had a space in an id attribute; like below?
    Code:
    <div id="Skills Assessment">
    
    </div>
    And you called it; like below?
    Code:
    <button onclick="show_book_form('Skills Assessment')">Book Now</button>
    If so, there is a reason for this; your not supposed to have white spaces, within the "id" attribute. So, that's probably why your getting errors.

    Here's some more reading; on above: https://developer.mozilla.org/en-US/..._attributes#id (read the "Usage note" >> list item number 2).
    Hi;

    No I dont think thats it There are no spaces in ids.
  12. #7
  13. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,123
    Rep Power
    119
    Post me an example of the exact occurrence; that your having issue with; post both your html and js snippet, that way I can take a look @ it.
  14. #8
  15. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by web_loone08
    Post me an example of the exact occurrence; that your having issue with; post both your html and js snippet, that way I can take a look @ it.
    Code:
    <?php include "header.php";?>
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <style type="text/css">
    .more_less { display:none;} 
    </style>
    <script>
    	function show_hide(id)
    		{
    			$('#' + id).show("blind")
    			$(".more_less").hide();
    			
    		}
    </script>
    
    <div class="post">
      <h1>Services</h1>
      <p><strong>We offer a variety of personalised, one on one service's for allyour Australian Visa and Immigration needs.</strong></p>
      <p> You can find out more about the services that we offer by simply clicking on one of the links below, however I recommend that you start with our Assessment as this will help determine what Australian immigration options are available to you:</p>
      
      <p><a  onclick="show_hide('sa'); return false();">Skills Assessment</a></p>
      
      
      <div class="more_less" id="sa"><p><strong>The success of any visa or Australian immigration application depends on the suitability of the applicant.</strong> </p>
      <p>Separate from your Suitability Assessment, the Skills Assessment is designed for those people who want to migrate to Australia as a skilled migrant.    </p>
      <p>There are a number of steps involved if you decide you want to come to Australia as a skilled migrant, such as making sure that the skill you are nominating for is on the Skilled Occupation List. And if it is you then need to prove that your skills have been assessed as being suitable for the occupation that you have chosen.    </p>
      <p>In addition to this there can be differences in licensing and registration requirements between the various states and territories of Australia. When it's all said and done there can be a lot of work involved in migrating to Australia as a skilled migrant.
        
        But our Skills Assessment service can guide you through the steps required. We work closely with you to give your application the best possible chance of success.</p>
      <p> So if you're keen to come to Australia as a skilled migrant let us help you by clicking on the link below.
        
        Click HERE to contact us about getting started on your Skills Assessment. </p>
    </div>
    
    
      <p><a  onclick="show_hide('sponsor'); return false();">Need a Sponsor?</a></p>
      <div class="more_less" id="sponsor"><p><strong>If you're looking for a permanent work visa, then the Employer Nomination Scheme (ENS) might be the best option for you.</strong> </p>
      <p>The Employer Nomination Scheme gives Australian employers the opportunity to sponsor highly skilled workers who are based overseas or currently in Australia as a highly skilled temporary resident.
        
        The advantage of this visa is that it gives you and any of your dependant family members who are included on your visa application, the chance to live in Australia as permanent residents.    </p>
      <p>We can assist you with these visa applications and have a network of businesses looking for highly skilled workers to sponsor. We take the hassle out of this process making it easy to match you with companies that might be seeking someone of your skills.
        
        Click HERE to discuss your sponsorship options. </p>
      </div>
      
      <p><a  onclick="show_hide('ss'); return false();">//Select</a></p>
      <div class="more_less" id="ss"><p><strong>Have skills or qualifications that you think could be off benefit to Australia?</strong> </p>
      <p>Then SkillSelect might be the service for you.
        
        SkillSelect is designed to help Australia meet any skill shortages in the workforce by allowing suitably skilled people to migrate to Australia.
        
        Often these skill shortages occur in regional areas of the country outside of major capital cities.    </p>
      <p>SkillSelect gives both employers and skilled workers wanting to migrate to Australia the opportunity to register their details through what is known as an Expression of Interest.
        
        STAR Migration can assist you in registering for this option, ensuring that you do so correctly to give yourself the best chance of success.
        
        Click HERE to contact us about helping you apply for SkillSelect. </p>
      </div>
      <p><a  onclick="show_hide('rs'); return false();">Resume Services</a></p>
      <div class="more_less" id="rs"><p><strong>If you're looking to work in Australia one of the first things you are going to need is a professional resume.</strong> </p>
      <p>The Employer Nomination Scheme gives Australian employers the opportunity to sponsor highly skilled workers who are based overseas or currently in Australia as a highly skilled temporary resident.
        
        STAR Migration can supply you with a professional resume that showcases your skills and qualifications in a format that Australian employers are looking for.</p>
    
      <p> If you need assistance in creating your resume, simply click HERE to contact us about your resume needs. </p>
        </div>
      <p><a  onclick="show_hide('va'); return false();">Visa Application</a></p>
      <div class="more_less" id="va"><p><strong>There are an enormous number of migration visas available and it's vitally important to select the correct one for your circumstances.</strong></p>
      <p>STAR Migration can assist you in selecting and then applying forthe correct visa for your needs including:
        
        Visa Application
        
        
        Choosing the right visa for your particular needs can be a confusing and stressful process.</p>
      <p> Let Star Migration take the stress out of this decision by assisting you through this process from selection, to application and hopefully right through to acceptance.
        
        Click HERE to find out more about the visa options that we can assist you with.</p>
      </div>
      <p><a  onclick="show_hide('bp'); return false();">Business Plans</a></p>
      <div class="more_less" id="bp"><p><strong>Want to start your own business in Australia? Or perhaps you're looking at investing in an existing one? </strong></p>
      <p>Either way a business plan should be considered vital to your chances of success.
        
        The STAR Migration business planning system is a functional document that not only assists with getting your application approved, it will also give you the strategies to make your business a tremendous success.    </p>
      <p>To find out more about our business plans simply contact us by clicking HERE</p>
      </div>
      <p><a  onclick="show_hide('ed'); return false();">Education</a></p>
      <div class="more_less" id="ed"><p><strong>Australia is a great place to study with a wide variety of internationally recognised courses and world class facilities.</strong></p>
      <p> SkillSelect is designed to help Australia meet any skill shortages in the workforce by allowing suitably skilled people to migrate to Australia.
        
        Australia has granted visas to students from over 190 countries, so the country you come from should not be seen as a negative. However the Australian Department of Immigration does have a process known as Assessment Levels in deciding which applications will or will not be successful.</p>
      <p> There are so many student visa options that it can become overwhelming, which is why our Education & Student Visa service offers such great value. We can assist you in identifying the right visa for your individual needs and then help you through the application process.</p>
      <p> Star Migration has a wealth of experience in this field and we guarantee to do everything in our power to assist you with your student visa needs.
        
        If you would like more information on how we can assist you in applying for your Student visa simply click HERE to contact us.</p>
    </div>
      <p><a onclick="show_hide('ed'); return false();">Do it yourself packages</a></p>
      <div class="more_less" id="dy"><p><strong>Purchase your STAR Migration DIY Kit here by clicking on the ADD TO CART button below.</strong> </p>
      <p>You are now only a few clicks away from downloading this DIY Migration Kit.</p>
      </div>
    </div>		
    <?php include "footer.php";?>
  16. #9
  17. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,123
    Rep Power
    119
    This:
    Code:
    show_hide('sa'); return false()
    Needs to be this:
    Code:
    show_hide('sa'); return false
    When a onClick event is occurring; your JS DOM is looking for a undefined function known as "false()", so your not actual preventing the default onClick event (with the way you currently, have your onClick events set-up).

    EDIT: Oh..., and... flip the hide() and show(); within your "show_hide(id)" function.
    Last edited by web_loone08; June 29th, 2013 at 09:25 PM.
  18. #10
  19. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by web_loone08
    This:
    Code:
    show_hide('sa'); return false()
    Needs to be this:
    Code:
    show_hide('sa'); return false
    When a onClick event is occurring; your JS DOM is looking for a undefined function known as "false()", so your not actual preventing the default onClick event (with the way you currently, have your onClick events set-up).

    EDIT: Oh..., and... flip the hide() and show(); within your "show_hide(id)" function.
    It it better but still doesn't close the already open ones.
  20. #11
  21. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,123
    Rep Power
    119
    Flip this
    Code:
    $('#' + id).show("blind")
    $(".more_less").hide();
    Make it this:
    Code:
    $(".more_less").hide();
    $('#' + id).show("blind");
    That is what I was referring to by this:
    Originally Posted by web_loone08
    EDIT: Oh..., and... flip the hide() and show(); within your "show_hide(id)" function.
    And..., then it should hide all open DIV elements and then open the DIV, with the specific "id" attribute you called in the parameter of your show_hide() function.
  22. #12
  23. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    It works many thanks.

    I had scriptaculous in header!!!!!

    Sorry about it
    Last edited by zxcvbnm; June 29th, 2013 at 11:08 PM.

IMN logo majestic logo threadwatch logo seochat tools logo