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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:23:21+00:00 2026-05-20T05:23:21+00:00

I have a form element, that is hidden or show depending on a dropdown

  • 0

I have a form element, that is hidden or show depending on a dropdown element in my form. I’ve been able to change the visibility when the dropdown changes.

Here’s my code right now:

$("select[name=post_category]").change(function(){
var id = $("select[name=post_category]").val();
if(id != 3){
    $("dt#post_url-label").hide();
    $("dd#post_url-element").hide();
}
else{
    $("dt#post_url-label").show();
    $("dd#post_url-element").show();
}
});

What I want is the fields to be hidden, unless the page loads with id=3 (so i can’t just hide them with CSS), in that case the field has to be visible from the start. Right now, the field is always visible on pageload.

Any suggestions how I should go about 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-20T05:23:22+00:00Added an answer on May 20, 2026 at 5:23 am

    Try this:

    $('select[name="post_category"]').change(function() {
        $('dt#post_url-label, dd#post_url-element').toggle( +this.value === 3 );
    }).change();
    

    The idea is to trigger the change event immediately. You should be able to achieve that by using either triggerHandler('change') or just change().

    Live demo 1: http://jsfiddle.net/XE78E/
    Live demo 2: http://jsfiddle.net/XE78E/1/

    The 2. demo shows that the element is visible if the 3-rd option is preselected.

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

Sidebar

Related Questions

I have a few hidden form elements like so: <input type=hidden name=numberOfAdults /> I
I have a form with multiple rows of text boxes. I use jquery .show()
I have a drop-down selector and form fields below. I need to be able
I have a set of tabbed divs that I am hiding and showing with
I have a webform with many input, checkbox, hidden, etc... elements and I am
I am trying to get the selected dropdown value and perform a slideDown on
I'm deleting a previously asked question and asking again more succinctly now that I
I am trying to use Authorize.net's SIM payment gateway process and am using the
I'm noticing what I think is a bug with Zend_Form_Element_File. Can others please test

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.