dtbam62840 2014-10-10 05:05
浏览 64
已采纳

yii在提交按钮显示确认消息两次

In my form, I have given a confirmation message before saving.

CHtml::submitButton('Save', array('confirm'=>'Are you sure you want to save?'));

But the message box appears two times... What is wrong ?

  • 写回答

2条回答 默认 最新

  • dongliyi967823 2014-10-10 10:33
    关注

    Here is the form where you can got the answer of your thing... this is one way of doing it...!!!

    <?php $form=$this->beginWidget('CActiveForm', array(
                                      'id'=>'customer-form-guest',
                                      'enableClientValidation'=>true,
                                      'clientOptions'=>array(
                                      'validateOnSubmit'=>true,
                                      'afterValidate' => 'js:function(form, data, hasError) { 
    
                                                          if(hasError) {
    
                                                                   alert("There are errors in form inputs please resolve it.");
    
                                                              }
                                                              else
                                                              {
    
    
                                                                var r = confirm("Are you sure y7ou want to do this ..?");
    
    
                                                               if(r == true)
                                                               {
                                                                  return true;
                                                               }
                                                               else
                                                               {
                                                                 return false;
                                                                }
    
    
    
                                                              }
                                                         }' ),
                                       'htmlOptions'=>array('role'=>"form"))); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?