douyi7283 2016-03-21 10:08
浏览 30

使EDIT按钮工作

<a href="#" data-target="#edit-order value="<?php echo $users[$i]['id']; ?>" name="delete-order" id="bb-confirm" data-placement="left" data-rel="tooltip" data-toggle="modal" data-original-title="Delete Order" class="btn btn-danger"><i class="fa fa-times icon-only"></i></a>

I want to parse the "value" info to this edit-order form and i didn't manage to make it work. I've tried with GET but nothing.

<div class="modal fade modal-scroll" id="edit-order" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus-circle"></i> Add Order</h4>
                </div>
                <div class="modal-body padding-2x">

                    <form role="form" method="post">
                        <div class="form-group">
                            <label>Order ID #</label>
                            <?php echo ORDER-ID-PASSED-FROM-BUTTON; ?>
                        </div>   

                        <div class="form-actions no-padding-bottom">
                            <div class="btn-group">
                                <button type="submit" name="edit-order" class="btn btn-primary">Update Order</button>
                            </div>          
                        </div>                                              
                    </form>

                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

Can somebody help me with this ? Thanks a lot

  • 写回答

1条回答 默认 最新

  • doude4924 2016-03-21 10:38
    关注

    If your modal dialog stay in the DOM you can use this code:

    var links = document.querySelectorAll('[data-target="#edit-order"]');
    [].forEach.call(links, function(link) {
       link.onclick = function() {
          var value = link.getAttribute('value');
          var group = document.querySelector('.modal form .form-group');
          var input = document.querySelector('.modal form .form-group input');
          if (input) {
              group.removeChild(input);
          }
          input = document.createElement('input');
          input.setAttribute('value', value);
          input.setAttribute('name', 'order');
          group.appendChild(input);
       };
    });
    

    or using jQuery:

    $('[data-target="#edit-order"]').click(function() {
       $('.modal form .form-group input').remove();
       var value = $(this).attr('value');
       $('.modal form .form-group').append('<input name="order" value="' + value + '"/>');
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图