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 6241453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:46:16+00:00 2026-05-24T11:46:16+00:00

I have the following html that when a user selects leasehold additional form fields

  • 0

I have the following html that when a user selects leasehold additional form fields appear:

<label for="hold_type">Leasehold / Freehold: </label>
<select id="hold_type" name="hold_type">
  <option value="null">--</option>
  <option value="lease">Leasehold</option>
  <option value="free">Freehold</option>
</select>
<span class="required">*</span>

<div class="section_hidden">
    <label for="lease_remaining">Years remaining on lease: </label>
    <input type="text" id="lease_remaining" name="lease_remaining" value="<?php if(isset($_SESSION['enquiryData']['lease_remaining'])); ?>" />
    <span class="required">*</span>
</div>

The jQuery I am attempting to use and adapt is:

$(document).ready(function() {
    $(".section_hidden").css("display", "none");
    $("select#hold_type").change(function() {
        if ($('select#hold_type option:selected').val() == "lease") {
            $('.section_hidden').fadeIn("fast");
            $('.section_hidden').css("display", "block");
            $.cookie('holdSection', 'expanded');
        } else {
            $(".section_hidden").fadeOut("fast"); //Slide Down Effect
            $(".section_hidden").css("display", "none");
            $.cookie('holdSection', 'collapsed');
        }
    });
});

There are more that one section_hidden divs on the page, hence the user selection should only show the div.section_hidden container that is below it rather the entire page. I have tried a combination of closest(), find() and next() but haven’t managed to get the desired result.

  • 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-24T11:46:17+00:00Added an answer on May 24, 2026 at 11:46 am

    You should use a wrapper element:

    <div class="wrapper">
        <label for="hold_type">Leasehold / Freehold: </label>
        <select id="hold_type" name="hold_type">
          <option value="null">--</option>
          <option value="lease">Leasehold</option>
          <option value="free">Freehold</option>
        </select>
        <span class="required">*</span>
    
        <div class="section_hidden">
            <label for="lease_remaining">Years remaining on lease: </label>
            <input type="text" id="lease_remaining" name="lease_remaining" value="<?php if(isset($_SESSION['enquiryData']['lease_remaining'])); ?>" />
            <span class="required">*</span>
        </div>
    </div>
    

    and the javascript:

    $(document).ready(function() {
        $(".section_hidden").hide(0);
    
        $("select#hold_type").change(function() {
            var $section_hidden = $(".section_hidden", $(this).closest(".wrapper"));
            if ($('select#hold_type option:selected').val() == "lease") {
                $section_hidden.fadeIn("fast");
                $.cookie('holdSection', 'expanded');
            } else {
                $section_hidden.fadeOut("fast"); //Slide Down Effect
                $.cookie('holdSection', 'collapsed');
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html/css that is causing problems in Firefox 1.5 and 2,
I have the following html.erb code that I'm looking to move to Haml: <span
I have a HTML file that has code similar to the following. <table> <tr>
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
I have the following HTML <select> element: <select id=leaveCode name=leaveCode> <option value=10>Annual Leave</option> <option
I have the following HTML. Currently it relies on the user hitting the 'Go'
To dynamically fill DropDown controls on my HTML Form, I have written code that
I have the following html <div id=active-el> <select id=select-drop> <option value=1>1</option> <option value=2>2</option> <option
I have a form on an HTML page with multiple submit buttons that perform
I have the following form: =form_for user, :validate=>true do |user_form| #avatar_id =user_form.fields_for :profile do

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.