Manage event from activeTextField

Hello, I am developing a new application, this have activeTextField which I want to activate a function that is in a class model, I use the following code to activate event in the view that display the activeTextField:

<div class="simple">

<?php echo CHtml::activeLabelEx($model,‘IdUsuario’); ?>

[b]<?php echo CHtml::activeTextField($model,‘IdUsuario’, array(‘onclick’ => ‘alert(1234)’)); ?>

[/b]</div>

<div class="simple">

<?php echo CHtml::activeLabelEx($model,‘TipoHoraLaboral’); ?>

<?php echo CHtml::activeDropDownList($model,‘TipoHoraLaboral’,TipoHoraLaboral::model()->TiposHoralaboral); ?>

</div>

This displays a message to verify that the event is working properly, so I can not do is call the function that is in the class of the model, but I don’t know how to call the function from the event activeTextField, someone could help me with this, or at least give me one example where you do something like that.

‘onclick’ occurs on the client side. You can’t directly call a model class method which is on the server side.

qiang is right. you can’t run a server side script for the client side event.

the only way to simulate this is using ajax

you can find hundreds of examples of ajax usage on this forum, here is one of them:

http://www.yiiframework.com/forum/index.php?/topic/3110-ajax-and-sidebar/page__view__findpost__p__17286


'success'=>'function(msg)

msg is the text or html returned by actionArticle() script.

if you are not familiar with ajax, try google articles and wiki