我希望在用户尝试单击“添加到收藏夹”时弹出警报
1) 如果没有选中任何复选框。
2)我还想知道如何获取复选框的值
这是我当前在后端的代码
<?php $this->widget('zii.widgets.grid.CGridView',array(
'id' => 'wsrecruitcvhead-grid',
'dataProvider' => $model->search(),
#'filter' => $model,
'columns' => array(
array(
'name' =>'',
'value' => 'CHtml::checkBox("rid[]",null,array("value"=>$data->ResumeID,"id"=>"rid_".$data->ResumeID))',
'type'=>'raw',
'htmlOptions' => array('width'=>5),
'visible' => !Yii::app()->user->isGuest,
),
array(
'name' => 'ResumeTitle',
'value' =>$model->ResumeTitle,
),
'ResumeSummaryIntroduction',
'Name',
array(
'class' => 'CButtonColumn',
'viewButtonUrl' => 'Yii::app()->createUrl("wsrecruitcvhead/view",array("id"=>$data["ResumeID"]))',
'template'=>'{view}',
),
),
)); ?>
这是屏幕截图http://pastebin.com/sEpJBCiU
最佳答案
希望这对您有帮助。
你的代码工作得很好,刚刚尝试过。我将使用 jQuery 实现您提到的功能,如下所示:
<script type="text/javascript">
$("input:checkbox").click(function () {
var thisCheck = $(this);
if (thisCheck.is (':checked')){
// do what you want here, the way to access the text is using the
// $(this) selector. The following code would output pop up message with
// the selected checkbox text
$(this).val());
}
});
</script>
此代码选择所有复选框类型的 DOM 元素,然后使用 if 条件检查是否被选中。 Here您可以找到有关此 jQuery 选择器的更多信息。 jQuery 是一个如此强大的工具!
关于php - Yii框架,CGridView复选框帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5295697/