将参数传递给具有数据目标的模态窗口无效

问题描述 投票:0回答:1

我设计了一页,其中包含一个以标签打开的模式窗口。我想将一些参数传递给模式窗口,该窗口将用于基于参数值填充表数据。它正在使用一个参数,但不适用于另一个参数。

下面是打开模式窗口的HTML ...

<table id="MyTable1" class="table table-sm table-striped table-lightfont paginated">
                  <thead class="thead-light">
                    <tr>
                      <th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GRP_DESC"); ?></th>
                      <th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?></th>
                      <th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GMA_ACCESS_FLAG"); ?></th>
                      <th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","OPTIONS"); ?></th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php
                    if ($_SESSION['$language']="E") {
                      $groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_desc,gma_module_id,module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id");
                    }
                    else {
                      $groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_bldesc as grp_desc,gma_module_id,module_blname as module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id");
                    }
                    foreach ($groupdata as $groupdatalist) {
                      //$allids[]=$groupdatalist["gma_id"]; ?>
                    <tr>
                      <td><?php echo $groupdatalist["grp_desc"];?></td>
                      <td><?php echo $groupdatalist["module_name"];?></td>
                      <?php if($groupdatalist["gma_access_flag"]=="N"):?>
                        <td style="text-align:right;width:10px;"><input type="checkbox" name="accessflag[]" id="accessflag"
                          value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
                      <?php else:?>
                        <td style="text-align:right;width:10px;"><input type="checkbox" checked name="accessflag[]" id="accessflag" width="10px"
                          value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
                      <?php endif;?>
                      <td style="display:none;"><?php echo $groupdatalist["gma_grp_id"];?></td>
                      <td style="display:none;"><?php echo $groupdatalist["gma_module_id"];?></td>
                      <td style="display:none;"><input type="text" name="gmaid" id="gmaid" value="<?php echo $groupdatalist["gma_id"];?>"></td>

                      <!--<td style="display:none"><input type="text" name="allids[]" value="<//?php echo "{$groupdatalist['gma_id']}"?>"/></td>-->
                      <td>
                        <span data-toggle="modal" data-target="#myModal-<?php echo $groupdatalist['gma_id'];?>">

                          <a href="#" class="btn btn-light btn-sm shadow-none"
                            data-toggle="tooltip" title="<?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MENUPERMISSION");?>">
                            <i class="fa fa-pencil-square-o"></i>
                          </a>
                        </span>
                      </td>
                    </tr>
                  <?php } ?>
                  </tbody>
                </table>

这是模式窗口HTML .....

<div id="myModal-<?php echo $groupdatalist['gma_grp_id'];?>" class="modal show fade" data-backdrop="static">
        <div class="modal-dialog modal-dialog-centered">
          <div class="modal-content">
            <div class="modal-header">
              <h6 class="modal-title">Menu List</h6>
            </div>
            <div class="modal-body">
              <div class="control-container" style="padding:10px;">
                <div class="row">
                  <div class="col-md-12" style="text-align:center">
                    <label style="color:red">
                      <?php //session_start();
                      if (!empty($_SESSION['$SaveMsg'])) { echo $_SESSION['$SaveMsg']; }
                      unset($_SESSION['$SaveMsg']);
                      ?>
                    </label>
                  </div>
                </div>
                <div class="row">
                  <div class="col-md-4">
                    <label><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GRP_DESC"); ?>
                    </label>
                  </div>
                  <div class="col-md-8">
                    <input class="text-control" type="text" name="grpid" id="grpid"
                    value="" readonly required maxlength="50" style="width:100%;display:none;" autofocus />
                    <input class="text-control" type="text" name="grpname" id="grpname"
                    value="" readonly required maxlength="50" style="width:100%" autofocus />
                  </div>
                </div>
                <div class="row">
                  <div class="col-md-4">
                    <label><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?>
                    </label>
                  </div>
                  <div class="col-md-8">
                    <input class="text-control" type="text" name="moduleid" id="moduleid"
                    value="" readonly required maxlength="50" style="width:100%;display:none" autofocus />
                    <input class="text-control" type="text" name="modulename" id="modulename"
                    value="" readonly required maxlength="50" style="width:100%" autofocus />
                  </div>
                </div>
                <?php $gmaid= "<script>document.writeln(gmaid);</script>";
                echo $gmaid;?>
<!--table starts here -->
<table id="MyTable2" class="table table-sm table-striped table-lightfont paginated">
  <thead class="thead-light">
    <tr>
      <th><?php echo GetBilingualLabels($_SESSION['$language'],"MENUACCESS","MENUNAME"); ?></th>
      <!--<th><//?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?></th>-->
      <th><?php echo GetBilingualLabels($_SESSION['$language'],"MENUACCESS","ACCESS_FLAG"); ?></th>
      <!--<th><//?php echo GetBilingualLabels($_SESSION['$language'],"MENUACCESS","OPTIONS"); ?></th>-->
    </tr>
  </thead>
  <tbody>

</table>
<!-- table ends here -->


                <div class="modal-footer">
                  <button type="button" class="btn btn-danger" data-dismiss="modal">
                    <i class="fa fa-close"></i>
                    <?php echo GetBilingualLabels($_SESSION['$language'],"BUTTON","CANCEL"); ?>
                  </button>
                  <button type="submit" name="updmenuperm" formnovalidate class="btn btn-primary"> <!--onclick="DispMsg(<//?php echo "'".$_SESSION['AlertMsg']."'";?>)"-->
                    <i class="fa fa-save"></i>
                    <?php echo GetBilingualLabels($_SESSION['$language'],"BUTTON","SAVE"); ?>
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>

以上代码运行正常,但是如果我使用另一个值作为参数,则根本不会打开模态窗口。对于前。如果我正在使用$ groupdatalist ['gma_id']这是整数值,则不会打开模式窗口。

php html bootstrap-modal
1个回答
0
投票

这里有多个问题。首先,末尾缺少</div>


然后您在foreach中定义$ groupdatalist,但尝试在循环外使用它:

<div id="myModal-<?php echo $groupdatalist['gma_grp_id'];?>" class="modal show fade" data-backdrop="static">

如果要每个<td>一个模态,则必须将模态移到foreach循环中。


最后,您使用$ groupdatalist ['gma_id']]调用模态

 <span data-toggle="modal" data-target="#myModal-<?php echo $groupdatalist['gma_id'];?>">

但是模态ID是使用其他变量定义的:$ groupdatalist ['gma_grp_id

']:
<div id="myModal-<?php echo $groupdatalist['gma_grp_id'];?>"
© www.soinside.com 2019 - 2024. All rights reserved.