如何在Modal上传递图像src Jquery

时间:2016-02-15 15:23:45

标签: javascript php jquery html

我需要你的帮助。所以这是我的问题。
如何从模态中传递图像src 我使用循环,数据在每个循环上动态变化

这是我如何将val传递给模态

中的字段
    <td><a href="" class="announce" data-toggle="modal" data-target="#myModal3" data-id="<?php echo $key->feedback?>" 
    data-name="<?php echo $key->report_by?>" data-title="<?php echo $key->recipe_title?>" data-violator="<?php echo $key->violator?>" 
    data-pic="<?php echo base_url()?>uploads/recipe/<?php echo $key->pic?>">

这是我的剧本

<script>
$(document).ready(function(){
   $(".announce").click(function(){ // Click to only happen on announce links
     $("#letter").val($(this).data('id'));
     $("#violator").val($(this).data('violator'));
     $("#reporter").val($(this).data('name'));
     $("#title").val($(this).data('title'));
     $("#pic").val($(this).data('pic'));
     $('#createFormId').modal('show');

   });
});   </script>

这是我的模式,所有细节必须显示

<div id="myModal3" class="modal fade " role="dialog">
    <div class="vertical-alignment-helper">
        <div class="modal-dialog vertical-align-center modal-md">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>

                    </button>
                     <center><h2 class="modal-title " id="myModalLabel"><span style="  color: #FE980F;  font-family: abel;font-size: 27px; text-transform: uppercase;">
              </span>

              <span style="color:black;">Additional details</span></h2></center>

                </div>
                <div class="modal-body">
                 // here is the problem I dont know what to put here.
                  Recipe Image:
                   <img src="" style="height:150px;width:150px;> 
                    <br>
                    Recipe Name:
                    <input type="text" id="title" class="form-control" readonly>
                    <br>
                    Violator: 
                    <input type="text" id="violator" class="form-control" readonly>
                    <br>
                    Report by:
                    <input type="text" id="reporter" class="form-control" readonly>
                    <br>
                    Additonal Information:
                    <textarea type="text"  id="letter" style="width:100%;height:300px;resize:none;"  readonly ></textarea>
                </div>

            </div>
        </div>
    </div>
</div>

感谢您的帮助。我真的很感激。快乐的编码家伙

0 个答案:

没有答案