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

  • SEARCH
  • Home
  • 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 7706629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:10:10+00:00 2026-06-01T00:10:10+00:00

I have the following mark up with a basic and advanced search divs. <div

  • 0

I have the following mark up with a basic and advanced search divs.

<div class="form">
     <form>
         <input type="text" name="first_name">
         <input type="text" name="last_name">

       <div id="Basic" class="slide">
         <input type="text" name="location"> 
       </div>

       <a onclick="ShowDiv('Adv');">+ show advanced fields</a>

      <div id="Adv" class="slide hidden">
         <input type="text" name="first_name2">
         <input type="text" name="last_name2">
         <input type="text" name="street">
         <input type="text" name="town">
         <input type="text" name="country">
       </div>
     </form>

     <a onclick="ShowDiv('Basic');">- hide advanced fields</a> 
    </div>

The toggle is achieved with the following script

 function HideDiv() {
         $('.slide').hide();
     }
     function ShowDiv(ctrl) {
         HideDiv();
         $('#' + ctrl).show();
     }
     ShowDiv('Basic'); 

I also have trhe following JQuery in place that shows the adv div if a user returns to the page from a results page assuming he completed any input fields from the search form initially

//show adv div based on input value data 
$(function(){
    if($("#Adv input[value!='']").length)
        $('#Adv').show(); // if this is the element you want to show.
 });

I need to eliminate the need of using both links. I need to have only one link depending on state. So if the div basic is shown as default the link will say show advanced. When the advanced is shown the anchor link should switch to hide advanced

How do I need to edit my jQuery and mark up.

  • 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-06-01T00:10:11+00:00Added an answer on June 1, 2026 at 12:10 am
    $(function(){
        $(".toggler").click(function(e) {
            e.preventDefault();
            $(this).find("span").toggle();
            $(".togglee").slideToggle();
        });
    
        //show adv div based on input value data 
        if($("#Adv input[value!='']").length) {
            $('.toggler').click(); // if this is the element you want to show.
        }
    
    });
    

    And the HTML:

    <html>
        <body>
            <div class="form">
                <form>
                    <input type="text" name="first_name">
                    <input type="text" name="last_name">
    
                    <div class="Basic togglee" class="slide">
                        <input type="text" name="location">
                    </div>
    
                    <div id="Adv" class="slide hidden togglee">
                        <input type="text" name="first_name2">
                        <input type="text" name="last_name2">
                        <input type="text" name="street">
                        <input type="text" name="town">
                        <input type="text" name="country">
                    </div>
                </form>
    
                <a class="toggle-link toggler">
                    <span>+ show advanced fields</span>
                    <span class="hidden">- hide advanced fields</span>
                </a>
    
            </div>
        </body>
    </html>
    

    jsFiddle example here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mark-up: <dt> <input id=p_method_checkmo value=checkmo type=radio name=payment[method] title=Check / Money
Say I have the following mark up: <label for=name>Name:</label> <input type=radio name=name id=name/> The
Problem I have the following mark-up: <div id=progress-bar> <div id=step-1 class=active><p>1. Select Room</p></div> <div
I have the following mark up of a div that contains a form. The
I have the following HTML mark up. <ul class=thumbs> <li> <strong>Should be level 0</strong>
I have following type of data and I want to produce bar graph. Mark
I have the following models: class Mark < ActiveRecord::Base validates_presence_of :user validates_presence_of :page belongs_to
I have the following mark-up: <table> <thead> ... </thead> <tbody> <tr> <td> <span class='select_me'
I have following source: class 'ParameterWert' /** * @ManyToOne(targetEntity=Parameter, inversedBy=Werte) * @JoinColumn(name=Parameter_histid, referencedColumnName=HistID) */
I have following text in a file 23456789 When I tried to replace the

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.