Hello again,
Today I want to update an activeTextField based on the selected option of an activeDropDownList through ajax.
But I don't know how to do many things:
Now I have the following:
<div class="simple"> <?php echo CHtml::activeLabelEx($invoice,'currencyID'); ?> <?php echo CHtml::activeDropDownList($invoice,'currencyID', CHtml::listData($currency,'id','name'), array('ajax'=>array('type'=>'GET', 'url'=>'index.php?r=currency/getRate', 'data'='id=1' // I pass 1 to test, but wath I want to pass es the id property of the selected currency ($currency->id) 'update'=>'#'.CHtml::getActiveId($invoice,'exchangeRate')))); ?> </div> <div class="simple"> <?php echo CHtml::activeLabelEx($invoice,'exchangeRate'); ?> <?php echo CHtml::activeTextField($invoice,'exchangeRate',array('size'=>10,'maxlength'=>10)); ?> </div>
My currency/getRate does the following:
<?php public function actionGetRate() { echo $this->loadMoneda()->rate; }
But I have two problems with all that:
1.- How I must pass the correct $currency->id (and not the '1' for test), I mean the id of the actual selected currency in the activeDropDownList.
2.- The update does not occur… (actualy if I put 'replace', the activeTextField is replaced for plain text (the velue returned from actionGetRate).
Note: If I run http:://myhost/myproject/index.php?r=currency/getRate&id=1 I get the correct answer. The answer is corrrect if id is 2 or 3, etc, etc.