【问题标题】:onsubmit cakephp icon change functiononsubmit cakephp图标更改功能
【发布时间】:2015-12-09 05:03:24
【问题描述】:
 <div class="bit-4 pad-small">
    <label>Cheque No</label>
    <?php echo $this->Form->input('cheque_no',array('label'=>false,'class'=>'custom-select','options' =>'' ,'empty' => '','required'));  ?> 
    <span>required</span>
  </div> 
   <div class="bit-4 pad-small">
    <label>DD No</label>
    <?php echo $this->Form->input('dd_no',array('label'=>false,'class'=>'custom-select','options' =>'' ,'empty' => '','required'));  ?> 
    <span>required</span>
  </div> 
 <div class="bit-4 pad-small"  style="float:none;">
        <br>
        <br>
     <?php echo $this->Form->input('approve', array(
                              'type'=>'checkbox', 
                               'style' => 'float:left;',
                               'label'=>'Approval of order',
                              'format' => array('before', 'input', 'between', 'label', 'after', 'error' ) 
       ) ); ?>
        <span>required</span>
       </div>
      <div class="bit-12" >
        <input type="submit"   value="Submit" class="form-submit button" />
      </div> 
    </div>

当我点击提交时,如果我点击批准,则必须显示一个绿色勾号,否则必须显示一个红色勾号。我该怎么办?

【问题讨论】:

  • 您需要在批准复选框更改时使用 jQuery 函数并根据条件执行 btn 颜色。

标签: javascript php jquery cakephp cakephp-2.0


【解决方案1】:

Put onChangeApprove 函数 onchange 事件的“批准按钮”。

function onChangeApprove(thisObj) {
    if ($(thisObj).is(":checked")) {
        //change btn color to Green
         $("#imgControl").attr("src","/../img/green.png")  

    } else {
        //change btn color to Red
         $("#imgControl").attr("src","/../img/red.png")  
    }
}

【讨论】:

  • 'onchange' => "javascript:onChangeApprove(this);",
  • 您需要更改哪个图像 src 添加该图像控件的 id 和 $("#imgControl").attr("src","/../img/red.png")或绿色。
  • 页面不应为此回发。如果页面发布打包然后您将获得批准的勾号真实值,那么您需要在 dom 准备好时执行 $("#approve").change()。
  • 1.使 'id'=> ''approve" 2. 在 $(document).ready(fucntion(){ $("#approve").change(); }) 处添加 $("#approve").change()
  • 我会自动将此讨论移至聊天室?但移至聊天室时出现错误。
猜你喜欢
  • 1970-01-01
  • 2018-01-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多