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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:00:06+00:00 2026-05-25T06:00:06+00:00

I need some help with Yii. How can I call a Controller action from

  • 0

I need some help with Yii.

How can I call a Controller action from a textbox onChange event?

Update:
I have a form built with CActiveForm. This form has many text-boxes. When I change any value other must be updated computing a formula using the new entered value. So what I am trying to do is the following:

    <tr>
        <td>Average KW Demand:</td>
        <td><?php echo $form->textField($lfac_model, 'kw_demand', array('size'=>5));?></td>
    </tr>
    <tr>
        <td>Estimated Load Factor:</td>
        <td><?php echo $form->textField($lfac_model, 'loadf', array('size'=> 5));?>/td>
    </tr>

When the user changes “Estimated Load Factor”, “Average KW Demand” value should be updated with the result of a formula. What I’ve figured out is to store the formulas in a table, then go to a Controller action, retrieve the specific formula, calculate the new value and send it back to the view. I’m not sure if this is the best idea to implement this.

  • 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-25T06:00:07+00:00Added an answer on May 25, 2026 at 6:00 am

    You should be able to use the CJuiAutoComplete Yii widget to do what you want. There is a basic demo here and there are other examples in the Yii docs. The main thing you would need to make sure in your case is that you also specify the “appendTo” option, see the jQuery autocomplete docs, which that widget uses.

    So basically, you would set up the widget for your “Estimated Load Factor” field, and point to the “Average KW Demand” field via the appendTo attribute.

    And if you don’t want the autocomplete stuff and simply want to replace the value, you can use the htmlOptions attribute “ajax” on your “loadf” value like so:

    'ajax' => array(
        'type'=>'POST', //request type
        'url'=>$this->createUrl('site/ajaxAction'), //url to call
        'success'=>'function(data) { $(\'#kw_demand\').val(data) }',// function to call onsuccess 
                 // "data" is returned data and function can be regular js or jQuery
    )
    

    see: CHtml#ajax-detail and jQuery.ajax. In this case you would most likely return plain text so your controller function would look like:

    public function actionAjaxAction() {
      [your data functions...]
      echo $kw_demand_string;
      Yii::app()->end()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
I need some help from the shell-script gurus out there. I have a .txt
need some help from a regex jedi master: If I have a string of
need some help with a MYSQL call. In one of my tables, I have
Need some help about with Memcache. I have created a class and want to
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help to solve this. I have a gridview and inside the gridview
Need some help assigning a mouseover event to display some icons that start out
Need some help here. I have deployed spree (0.70.3) on slicehost (ubuntu, ruby1.8.7, Rails
Need some help with below issue We have 2 machines, each of these machines

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.