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

The Archive Base Latest Questions

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

I have a category select that then loads up sub categories into a drop

  • 0

I have a category select that then loads up sub categories into a drop down, when sub category is selected, it should then load up different element via jQuery depending on their selection,

Heres the HTML

<li>
      <label for="cat">Choose The Category..</label>
      <select name="cat" class="required">
      <option type=""></option>
      <? 
      $conn = $db->query("SELECT * FROM categories WHERE parent_id = 0 ORDER BY name ASC");
        while($a = $db->fetch_array($conn)) {
            echo "<option value='{$a['category_id']}'>{$a['name']}</option>";
        }
        echo "</select>";
      ?>
      </select>
    </li>
    <li id="category">
    </li>

JS works like this

    $("select[name=cat]").change(function() {
    if($("select[name=cat] option:selected").val() != "") {
        $("#category").append(get_sub($("select[name=cat] option:selected").val()));
    }
});
$("select[name=category]").change(function() {
    if($("select[name=category] option:selected").val() != "") {
        $("#filters").append(get_filters($("select[name=category] option:selected").val()));
    }
});

Firs function loads up sub categories just fine, second function only works if I add the sub categories by hand, If I load up via JS, they don’t work, checked via firebug for the calls, only load up of sub categories happens, any ideas?

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

    You need to use live event handlers:

    Attach a handler to the event for all elements which match the current selector, now and in the future.

    Live event listeners are attached on the document root. When they are fired, jQuery will check the selector you passed in to see if the element matches. This allows you to listen for events on elements that match that selector now and the future.

    Example (untested):

    $("select[name=cat]").live('change', function() {
        if($("select[name=cat] option:selected").val() != "") {
            $("#category").append(get_sub($("select[name=cat] option:selected").val()));
        }
    });
    $("select[name=category]").live('change', function() {
        if($("select[name=category] option:selected").val() != "") {
            $("#filters").append(get_filters($("select[name=category] option:selected").val()));
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have a select input: f.select :category_id, nested_set_options(Category, @categories) {|i| #{'-' * i.level} #{i.name}
I have an existing drop down menu that I am attempting to convert to
I have a following HQL query: SELECT s.id FROM stack s WHERE s.category is
I have sql statement one; select linkscat.id, linkscat.category from linkscat, contentlinks, links where contentlinks.linksid
What I have is following: <xsl:variable name=myvar select=.//spss:category[((not @varName) or @varName=$colVarName) and @text=$series]/spss:cell/@text/> What
I have a category system that is related many-to-many with posts. How can I
Lets suppose that I have a Category table with a column that holds the
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
if i have a category page that im rendering by querying the subcategories in

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.