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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:56:02+00:00 2026-05-27T19:56:02+00:00

I have two database tables, grouptypes and groups. A grouptype can have multiple groups,

  • 0

I have two database tables, grouptypes and groups. A grouptype can have multiple groups, but a group only belongs to one grouptype. I have two select tags, one is grouptypes and another one is groups.

What I want to do is that whenever a user selects a grouptype in the grouptypes dropdown menu, it triggers a handler to retrieve the corresponding groups that belong to that grouptype, and pass it to the second select dropdown list.

I have the code as follows. It has not been completed and there are some errors. Can anyone help?

  <?php
    $result = $_POST['grouptype'];
    echo $result;
  ?>

  GroupType: <select id="groupTypes">

    <?php foreach($grouptypes as $type) : ?>

    <?php echo "<option value='" . $type->name . "'>" .$type->name. "</option>"; ?>

    <?php endforeach ?>

  </select><br />

  <br />
  Group: <select id="groups">
    <?php $count = 0; ?>
    <?php foreach($groups as $group) : ?>
    <?php $count++; ?>
    <?php echo "<option value='" . $group->name . "'>" .$group->name. "</option>"; ?>

    <?php endforeach ?>

  </select><br />



  <script type="text/javascript">

    $('#groupTypes').change(function(){

      var grouptype = $('#groupTypes').val();
      $.post("GroupModificationSuccess.php", {grouptype: grouptype});
    });

  </script>
  • 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-27T19:56:03+00:00Added an answer on May 27, 2026 at 7:56 pm

    This should work, might need some tweaks

    $(function(){
    
    
    var GType  = $("select#groupTypes"),
        GGroup = $("select#groups").hide(),
        GData  = [];
    
    GType.bind('change', function(){
    
        //grab the value of the option currently selected
        var optselected = $(this).find("option:selected").val();
        if(optselected)
        {
         //send post data and request a callback
         $.post("GroupModificationSuccess.php", {'grouptype' : optselected}
         , function(callback)
               {
                     if(callback)
                     {
                         GData.push(callback.data);  
                     }
               });
         }
    
         //loop data send back via callback and build options
         $.each(GData, function(key, val))
         {
             var opts = '';
             opts += '<option value='+ key + '>' + value + '</option>'      
         }
         //append options to Group select and show it
         GGroup.append(opts).show().fadeIn('slow');
    });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two database tables. A group contains multiple members. Groups: Id
I have two related tables in my database: Page and Tag. One Page can
I have two database tables with a one-to-many relationship. Is it possible to select
I have two database tables, subscription and transaction , where one subscription can have
I have two database tables, one for Users of a web site, containing the
I have two MySQL database tables: one containing a list of championships and another
I have two database tables. One table stores data for a commitment that a
I have two database tables, one in MYSQL and one in MSSQL. Both have
I have two database tables with the following structure: actions: action_id int(11) primary key
I have a database two tables and a linking table that I need a

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.