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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:55:36+00:00 2026-06-04T18:55:36+00:00

I have 3 dropdown lists. 1) Type 2) Duration 3) Class <select name=passenger_type_of_pass class=pass>

  • 0

I have 3 dropdown lists.
1) Type
2) Duration
3) Class

<select name="passenger_type_of_pass" class="pass">
    <option value="">- - Type - -</option>
    <?
       $result_type_of_pass = myquery($type_of_pass);                                           
       while($row = mysql_fetch_array($result_type_of_pass))
       {
          echo "<option value=\"" . $row['product_name'] . "\">" . $row['product_name'] . "</option>";  
       }
    ?>
</select>

<select name="passenger_duration" class="duration">
    <option>--Duration--</option>
</select>

<select name="passenger_class" class="class">
    <option>--Class--</option>
</select>

Using jQuery, I make them updated as there is change in each select box.

        $(".pass").change(function()
        {
            var pass=$(this).val();
            var dataString = 'pass='+ pass;

            $.ajax
            ({
                type: "GET",
                url: "duration.php",
                data: dataString,
                cache: false,
                success: function(html)
                {
                    $(".duration").html(html);
                }
            });

        });

        $(".duration").change(function()
        {
            var duration=$(this).val();
            var pass=$(".pass").val();
            var dataString = 'pass='+ pass + '&duration=' + duration;

            $.ajax
            ({
                type: "GET",
                url: "class.php",
                data: dataString,
                cache: false,
                success: function(html)
                {
                    $(".class").html(html);
                }
            });

        });

I want to change this code in such a way that as soon as I select “type_of_pass”, the “duration” dropdown list gets populated and also the top option gets SELECTED!!
With this auto-selected duration, jQuery for searching the class runs and gets populated with the top option selected.

Currently with my code, I have to CHANGE the duration to get the class populated.

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-04T18:55:37+00:00Added an answer on June 4, 2026 at 6:55 pm

    Trigger a change event after populate them like

    $('.duration').change():
    

    CODE:

    $.ajax({
        type: "GET",
        url: "duration.php",
        data: dataString,
        cache: false,
        success: function(html) {
            $(".duration").html(html);
            $(".duration").change(); // here to trigger a change
        }
    });
    

    To set any specific options you can do

    $('.duration option:eq(1)').prop('selected', true); // here I set the second option
    

    DEMO

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

Sidebar

Related Questions

I have a dropdown list in my django template: <select name=submit_new id=submit_new> <option value=Stdo>Studio</option>
I have a dropdown list that stores name/value pairs. The dropdown appears in each
I have 2 dropdown lists on my webform and using jquery trying to filter/reset
I have a 2 dropdown lists side by side. When user selects from the
Currently I have a web application where a user can use dropdown lists to
i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
I have a dropdown list and a select list. Both contain quite a few
I have two dropdown lists (one dynamically populated, the other not) that determine the
I have two dropdown lists: <asp:DropDownList ID=Field_Type runat=server /> <asp:DropDownList ID=Field_SubType runat=server /> Field_Type
I have a dropdown bar - <div class=buttonContainer> <ul> <li> <a class=menu1one href=>Dashboard</a> </li>

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.