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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:16:55+00:00 2026-06-08T19:16:55+00:00

I’m working on a new website based on CodeIgniter. I’m trying to hide some

  • 0

I’m working on a new website based on CodeIgniter. I’m trying to hide some elements to my form depending on an input value, but the field doesn’t hide but stays disabled.

Here’s the code I have :

HTML :

<div class="clearfix">
    <label for="form-timezone" class="form-label">Filters<small>Options</small></label>
    <div class="form-input">
        <?php 
            echo form_dropdown('filter', $filters,'', 'id="form-timezone"');
            echo form_dropdown('city', $cities, '', 'id="city"');
            echo form_dropdown('country', $countries, '', 'id="country"');
        ?>
    </div>
</div>

Which basically gives something like :

<div class="clearfix">
    <div class="form-input">
        <select name="filter" id="form-timezone">
            <option value="city">City</option>
            <option value="country">Country</option>
        </select>
        <select name="cities" id="city">
            <option value="Paris">Paris</option>
            <option value="London">London</option>
        </select>
        <select name="countries" id="country">
            <option value="fr">France</option>
            <option value="en">England</option>
        </select>
    </div>
</div>

JS :

$(function() {

    $("#city").hide();
    $("#country").hide();

    $("#form-timezone").change(function() {
        if ( $("#form-timezone").val() == "city"){
            $("#city").show();
            $("#country").hide();
        }
        else if ( $("#form-timezone").val() == "country"){
            $("#city").hide();
            $("#country").show();
        }
    });
});

I tried to add an <input> field to my html, and to hide it in the js, and it worked well. I don’t know why, but it seems that only the form_dropdown doesn’t hide…

Do someone has an idea of what I’m doing wrong please ?

Thanks.

  • 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-08T19:16:56+00:00Added an answer on June 8, 2026 at 7:16 pm

    I don’t know what you mean by not working. But your code can be a lot simpler with no if statements.

    $("#form-timezone").change(function() {
         var el =  $('#' + $(this).val()); // <-- store matched element
         el.show();  // <-- show matched element
        $("#country,#city").not(el).hide(); // <-- hide unmatched element
    });
    

    And they work fine in this fiddle (they hide and not disable) – tested in Firefox/Chrome/IE9

    http://jsfiddle.net/5LNWr/1/

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

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported

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.