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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:59:36+00:00 2026-06-07T00:59:36+00:00

I’ve searched all over for an answer to this, but cannot find any clear

  • 0

I’ve searched all over for an answer to this, but cannot find any clear examples for what I’d like to do. I have worked to provide this functionality in native JavaScript (getDocumentiD) in the past, but I’d like to know the easiest way to do this in the Yii framework.

What I’d like to do is using the CJuiAutoComplete class, autofill particular fields by adding, dividing, or multiplaying values given from PREVIOUSLY entered fields in a form. I would like this to update dynamically as the values are changed. If anyone could outline the appropriate steps or examples, or a link to a guide I would greatly appreciate it!

I would also like to achieve something similar for one particular field in my form. What I’d like to do is given the input from a previous field e.g (country name), look up my database for that model all corresponding rows that contain that same previously entered country from the form, take the average of an integer in a column for all those rows, and autofill ANOTHER field on the form.

If anyone could give any clear examples of this I would greatly appreciate it.

  • 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-07T00:59:38+00:00Added an answer on June 7, 2026 at 12:59 am

    I don’t think CJuiAutoComplete will do what you’re hoping to do, as that class is a wrapper around http://jqueryui.com/demos/autocomplete/, which basically provides suggestions as you complete a form, not calculating values based upon other form inputs.

    For your question, the general overview is that you’ll want to attach an AJAX call to your listbox in your view, something along the lines of:

    echo CHtml::listBox('country', '', array('country1', 'country2'),
        array('ajax' => array(
                    'type' => 'POST',
                    'url' => Controller :: createUrl('/controller/parseData'),
                    'dataType'=>'json',
                    'success'=>'function(data) {
                        $("#secondField").val(data.returnValue);
                    }'
                    ),
            'id'=>'countrySelect',
        )
    );
    

    The above code creates a listbox with attached AJAX. In your controller, you’d then have something like:

    public function actionParseData() {
       if (Yii::app()->request->isAjaxRequest) { 
           $country = $_POST['country'];
           // php code to parse the submitted data, 
           // i.e.. query the DB and run your calcuations
           // and finally return the data, using a line of the form:
           echo CJSON::encode(array('returnValue'=>$valueYouCalculated));
        }
    }
    

    The auto-update then happens as the success function in the AJAX is called, and the part of the page with id ‘secondField’ will be updated to have the value you returned.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from

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.