weixin_33725807 2018-03-12 08:14 采纳率: 0%
浏览 535

.modal('show'); -不显示模式

im trying to show a modal that will show textboxes with values from the table i displayed. im using this code to trigger the modal: $('#updatemodal').modal('show'); but it's not working.

this is the script for transferring the table contents to the modal and displaying the modal as well:

<script>
    $(document).on('click','.edit_data',function(){  
       var awardee_id = $(this).attr("uawardeeid");  
       $.ajax({  
            url:"fetchawardees.php",  
            method:"POST",  
            data:{awardee_id:awardee_id},  
            dataType:"json",  
            success:function(data){  
                 $('#updatemodal').modal('show');
                 $('#uawardeeid').val(data.awardee_id);   
                 $('#uawardeename').val(data.awardee_name);   
                 $('#uawardeeaddress').val(data.awardee_address);   
                 $('#uawardeecontact').val(data.awardee_contact_info);   
                 $('#uaward').val(data.award_id);   
                 $('#ucategory').val(data.category_id);   
                 $('#uregion').val(data.region_id);   
                 $('#uprovince').val(data.province_id);   
                 $('#uimage').val(data.awardee_img);   

            }  
       });  
  }); 

this is the code for the modal contents:

            <form class="form-horizontal" id="updateform" name="updateform" action="phpawardee.php" method="POST" enctype="multipart/form-data">
        <div class="modal fade in" tabindex="" role="dialog" aria-hidden="false"  name="updatemodal" id="updatemodal">   
            <div class="modal-dialog modal-lg" >
                <div class="modal-content" >
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title">Edit Awardee</h4>
                    </div>
        <div class="modal-body">  

                <div class="panel-body">
                          <input id="uawardeeid" name="uawardeeid" type="text" class="form-control">
                                <fieldset>
                                    <!-- Name input--> 
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="name">Awardee Name</label>
                                        <div class="col-md-9">
                                            <input id="uawardeename" name="uawardeename" type="text" placeholder="" class="form-control"></div>
                                    </div>
                                    <!-- Address body -->
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="message">Address</label>
                                        <div class="col-md-9">
                                            <textarea class="form-control resize_vertical" id="uawardeeaddress" name="uawardeeaddress" placeholder="" rows="4"></textarea>
                                        </div>
                                    </div>
                                    <!-- Contact info input-->
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="name">Contact Info.</label>
                                        <div class="col-md-9">
                                            <input id="uawardeecontact" name="uawardeecontact" type="number" placeholder="" class="form-control" ></div>
                                    </div>
                                    <!-- Level of Award input-->
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="email">Level of Award</label>
                                        <div class="col-md-9">
                                            <select id="uaward" name="uaward" class="form-control">
                                                <option>Select</option>
                                                    <?php
                                                        $res=mysqli_query($db, "select * from tbl_award_level");
                                                        while($row=mysqli_fetch_array($res))
                                                        {
                                                    ?>
                                                 <option value="<?php echo $row["award_id"]?>"><?php echo $row["award_name"]; ?></option>
                                                    <?php
                                                        }
                                                    ?>
                                            </select></div>
                                    </div>
                                    <!-- Store Category-->
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="email">Store Category</label>
                                        <div class="col-md-9">
                                            <select id="ucategory" name="ucategory" class="form-control">
                                                <option>Select</option>
                                                    <?php
                                                       $res=mysqli_query($db, "select * from tbl_store_category");
                                                     while($row=mysqli_fetch_array($res))
                                                       {
                                                    ?>
                                                <option value="<?php echo $row["category_id"]?>">
                                                    <?php echo $row["category_name"]; ?></option>
                                                    <?php
                                                            }
                                                    ?>
                                            </select></div>
                                    </div>
                                    <!--Region-->
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">Region</label>
                                        <div class="col-md-9">
                                            <select id="uregion" name="uregion" class="form-control" onChange="change_region2()">
                                                <option>Select</option>
                                                    <?php
                                                        $res=mysqli_query($db, "select * from tbl_region");
                                                        while($row=mysqli_fetch_array($res))
                                                            {
                                                    ?>
                                                <option value="<?php echo $row["region_id"]?>">
                                                    <?php echo $row["region_name"]; ?></option>
                                                    <?php
                                                            }
                                                    ?>
                                            </select></div>
                                    </div>
                                     <!-- Province-->
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">Province</label>
                                        <div class="col-md-9">
                                            <select id="uprovince" name="uprovince" class="form-control">
                                                <option>Select</option>
                                                <option></option>

                                            </select></div>
                                    </div>
                                    <!--File Upload-->
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="name">Choose Photo</label>
                                        <div class="col-md-9">
                                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                                <div class="form-control" data-trigger="fileinput" >
                                                    <i class="glyphicon glyphicon-file fileinput-exists"></i>
                                                    <span class="fileinput-filename"></span>
                                                </div>
                                                <span class="input-group-addon btn btn-default btn-file">
                                                    <span class="fileinput-new">Select file</span>
                                                    <span class="fileinput-exists">Change</span>
                                                    <input type="file" name="uimage" ></span>
                                                <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                <button type="button" data-dismiss="modal" class="btn btn-default">Close</button>

                                <button type="submit" class="btn btn-primary" id="updatebutton" name="updatebutton">Update</button>
                            </div>
                                    <!-- Form actions -->
                                </fieldset>

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

and here is the code of the button i should click to show the modal:

<a name="edit" value="Edit" data-toggle="modal" id="<?php echo $awardee["awardee_id"]; ?>" class="btn btn-md btn-primary edit_data" >Edit</a>
  • 写回答

2条回答 默认 最新

  • weixin_33686714 2018-03-12 08:49
    关注

    There is a mistake in your code.

    you have used

    var awardee_id = $(this).attr("uawardeeid");
    

    But in your button you are not mentioning "uawardeeid".

    <a name="edit" value="Edit" data-toggle="modal" id="<?php echo $awardee["awardee_id"]; ?>" class="btn btn-md btn-primary edit_data" >Edit</a>
    

    In your jQuery replace

    var awardee_id = $(this).attr("id");
    

    Hope it helps.

    Thanks.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?