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

The Archive Base Latest Questions

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

This is the dropdown am using.. <?php echo $form->labelEx($model,’status’); ?> <?php echo $form->dropDownList($model,’status’, array(‘0’

  • 0

This is the dropdown am using..

    <?php echo $form->labelEx($model,'status'); ?>
            <?php echo $form->dropDownList($model,'status',
array('0' =>'In active', '1'=> 'Active'),
array( 'onChange' => 'javascript:description()' )); ?>

How can i display a text box for description on selecting inactive dynamically…

please suggest some yii + ajax tutorials for beginners

  • 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:50:48+00:00Added an answer on May 27, 2026 at 7:50 pm

    What you’re are trying to do is actually pretty simple, and, thanks to Yii’s jQuery encapsulation, you don’t need to worry about jquery code. Here is the reference: http://www.yiiframework.com/wiki/24/creating-a-dependent-dropdown#hh0 Anyway, let me show you how to do it. But before I have a question for you: does this line of code: array( 'onChange' => 'javascript:description()' ), was your attempt to solve this problem? Or does it has another functionality unrelated to this topic? If it is part of your attempt to solve the problem, then just delete it. You won’t need that. As I told you before, you don’t need to worry about actual jquery code, it is well encapsulated in Yii. Other way, if it is unrelated to this topic, let it where it is, of course.

    Now, about the ajax update. First all all, we need a div where the text box will be displayed; I’ll use the description_id div. Then, the ajax request is specified inside the dropdownlist() as follows:

    <?php echo $form->labelEx($model,'status'); ?>
    <?php echo $form->dropDownList($model,'status',
    array('0' =>'In active', '1'=> 'Active'),
    array( 'onChange' => 'javascript:description()', 
           'ajax'=>array(
              'type'=>'POST',
              'url'=>CController::createUrl('YourController/actionWhichEchoesTheTextBox'),
              'update'=>'#description_id',
    ))); 
    ?>
    <div id="description_id">
    </div>
    

    You may notice that in the ‘url’ attribute of the ajax declaration we specified the function which will be called when the ajax request triggers. In the ‘update’ attribute we specified the div where will be displayed the result of calling the function specified in the url attribute.

    Finally, all that’s left to do is declare the action actionWhichEchoesTheTextBox(). It can be declare in any controller, but if it is not in the current controller, then you have to declare it as static method in order to make it accessible here. So to avoid any problem, you should declare it in the current controller, and it would look something like this:

        public function actionWhichEchoesTheTextBox()
       {
          if($_POST['ModelName']['status']===0)
             echo CHtml::textField("ModelName", 'description'/*attribute name*/) ; 
       }
    

    And that’s it.

    • 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. I am using onchange event of this dropdown to
I am using following code to populate DropDown: $(document).ready(function(){ $('#inDistrict').sSelect(); $(#inDistrict).change(function(){ $.getJSON(filldistricts.php,{id: $(this).val(), ajax:
I built a Jquery dropdown menu using this tutorial . It works across browsers
I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
Basically, I have populated a dropdown list using php from a database on a
I am generating options for my dropdown using // view.php foreach ($plants as $row):
I am using dialog to display a form and echo back message on submission.
I am filling DropDown dynamically using AJAX. The DropDown code looks like this: <select
I want to output the value from a dropdown menu using an echo but
I am using this code in my form to create a drop down menu.

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.