you can use your existing code for rendering the dropdown menu in html. Yii should give that dropdown automatically a unique id, so you can use that to replace the "#dropdown’ in jquery code. The ‘#show_dropdown_content’ must be added manually in your view.
Best practise to render your jquery code is to use CClientScript. You should take a look at the functions “registerScript” and “registerScriptFile”. So if you don’t want to move your javascript code in a external script file you can do:
<?php
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerScript('dropdown', '
$("#dropdown").change(function() {
var content = $("#dropdown option:selected").text();
$("#show_dropdown_content").text("You have selected: "+content);
});
');
?>
Simply add this code at the top of your view file.
[*]You don’t need to register jQuery: you’re probably using a CActiveForm in your view, so Yii already registers jQuery for you (as well as the yiiactiveform jQuery plugin). Moreover, registerScript when used with the default position registers itself jQuery.
[*]Instead of text(), I’d use val() to retrieve the selected option, and html() to set the div contents.