Good day guys can you please help me create a simple jquery code in my yii _form im new to yii and i want to test a simple code that will simply pop-up a message when a textbox was clicked.
Good day guys can you please help me create a simple jquery code in my yii _form im new to yii and i want to test a simple code that will simply pop-up a message when a textbox was clicked.
<?php echo CHtml::textField(‘Text’, ‘some value’, array(‘id’=>‘idTextField’, ‘width’=>100, ‘maxlength’=>100); ?>
<script type = "text/javascript>
[size=2]$( "#idTextField" ).click(function() {[/size]
alert( "Clicked" );
});
[size=2]</script>[/size]
Hi,
Its better way of previous version
<?php echo CHtml::textField(‘Text’, ‘some value’, array(‘id’=>‘idTextField’, ‘width’=>100, ‘maxlength’=>100); ?>
[size=2]Yii::app()->clientScript->registerScript([/size]
'testjs',
'[size=2]$( "#idTextField" ).click(function() {[/size]
alert( "Clicked" );
});
',
CClientScript::POS_READY
);
Thanks man, this helps me to move forward of my work
thanks Im having a hard time because of the framework but now thanks to you i learned the way to use jquery in Yii