2013-05-31 25 views
0

我有一个问题,我在yii中是一个新手,我吸入ajax。 假设我有警予形式看起来像:从ajax获取yii表单中的字段的值

<?php echo $form->dropDownListRow($model,'study_type_id', $studyTypeList, array(
     'options'=>array($default['studyTypeId']=>array('selected'=>true)), 
     'id'=>'study-type-list', 
     'class'=>'span5 study-create-input') 
); ?> 

说,在下拉菜单中选择向下是“studytype1”,“studytype2” ..等..

如何访问这些选项字符串形式..(对不起的解释)..在ajax脚本说..

Yii::app()->clientScript->registerScript('generateStudyName', " 
     var updateStudyName = function() { 

var studyType = ??//I want to access the value selected in the drop down list 
that i hope to use 

}"); 

谢谢!

回答

1

$('#study-type-list').val()会给你下拉元素的选定值。

使用此选项可获取选定的选项文本。

$('#study-type-list option:selected').text(); 
+0

非常感谢! – muffin

相关问题