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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:50:43+00:00 2026-06-17T19:50:43+00:00

I need to show two dependent drop-down lists in my page. If we select

  • 0

I need to show two dependent drop-down lists in my page. If we select an item from first drop-down list, based on the item which we selected, it should filter the entries in the second drop-down list, then I need to perform a search using the value in the second drop-down list. But the thing is that the values come from the table to show in the first drop-down list is not an active record of it. Can anyone help on this?

Currently I have that second drop-down list in place and it can perform a search based on the selected value. Now what I need to do is place a drop-down list above this and filter the items based on the first drop-down list.

Edit

1st table – client_id, client_name – items in the first drop-down list should show client names

2nd table – program_id, client_id, program_name –

3rd table – ad_id, program_id, ad_name – the second drop-down list should show ad_names filtered by using client_id.

  • 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-17T19:50:44+00:00Added an answer on June 17, 2026 at 7:50 pm

    Finally I did that, here is it.

    In my controller,

    public function actionDynamicDropdownList()
       {
        if($_POST['client_id'] > '0') {
            $result = Yii::app()->db->createCommand()->select('program_id, program_name')->from('program')->where('client_id='.$_POST['client_id'].'')->order('program_name')->queryAll();
            $this->render('admin', array(
                'result' => $result,
            ));
          }
    }
    public function actionDynamicProgramsList()
    {
        if($_POST['program_id'] > '0') {
            $results = Yii::app()->db->createCommand()->select('ad_id, ad_name')->from('ads')->where('program_id='.$_POST['program_id'].'')->order('ad_name')->queryAll();
            $this->render('admin', array(
                'results' => $results,
            ));
        }
    }
    

    and in my view, I have added

    <?php
    $data = Yii::app()->db->createCommand()->select('client_id, client_name')->from('client')->order('client_name')->queryAll();
    echo CHtml::dropDownList('client_id', '',CHtml::listData($data,'client_id','client_name'), array(
    'empty'=>'- Select Client Name -',
    'ajax'=> array(
    'type'=>'POST',
    'url'=>Yii::app()->baseUrl.'/index.php?r=page/dynamicDropdownList',
    'update'=>'#program_id'))); 
    
    //empty since it will be filled by the above dropdown
    echo CHtml::dropDownList('program_id','', CHtml::listData($result,'program_id','program_name'), array(
    'empty'=>'- Select Program Name - ',
    'onchange'=>'alert(this.value);',
    'ajax'=> array(
    'type'=>'POST',
    'url'=>Yii::app()->baseUrl.'/index.php?r=page/dynamicProgramsList',
    'update'=>'#ad_id')));
        //empty since it will be filled by the above dropdown
    echo CHtml::dropDownList('ad_id','', CHtml::listData($results,'ad_id','ad_name'), array(
    'empty'=>'- Select Ad Name - ',
    
    ));
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with a ScriptManager, a generic HTML drop-down list ( <select>
tl;dr: I need to show data from two different tables in the list view
I need to show two different videos at the same time within my iOS
I have two grids, thay both have one store. I need to show everything
I need to show non available dates in different color based on the event
I need to show more than one report on a Page like Classic Report,
on the site I'm working on, I need to show two different HTML snippets
I need to show two labels hello and world, one at leftmost, and the
I need to make two columns from single column price depending upon if it
I would like to show several columns from the orders table, one of which

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.