将隐藏的输入类型传输到我隐藏的模态/表单

时间:2015-02-21 03:31:37

标签: javascript php html forms

所以场景是,我有一排订单详情。当我点击"详细信息"该订单的按钮将弹出隐藏的表单,其中包含订单的详细信息。我的问题是如何将该行的详细信息(可能只有order_id)转发给隐藏的表单。到目前为止,这是我的代码。

//数据表

<tbody>

    <?php 


         $Query = mysqli_query($conn, "SELECT * FROM job_request");
          while($row_orders = mysqli_fetch_array($Query)) {
            echo      "<tr >
                      <td class='v-align-middle'><button class='btn btn-warning' data-toggle='modal' data-target='#newOrders'> Details </button></td>

                      <td class='v-align-middle'>". $row_orders['cust_id']."</td>
                      <td class='v-align-middle'><span class='muted'>". $row_orders['proj_type']."</span></td>
                      <td><span class='muted'>₱". $row_orders['tot_amt']."</span></td>
                      <td class='v-align-middle'>
                       <div class='progress'>
                          <div data-percentage='100%'  class='progress-bar progress-bar-warning animate-progress-bar'></div>
                        </div>
                     </td>
                    </tr>";

                    }
     ?>

</tbody>

//隐藏表格

<!-- Modal -->
                  <div class="modal fade" id="newOrders" 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>
                          <br>
                          <i class="icon-credit-card icon-7x"></i>
                          <h4 id="myModalLabel" class="semi-bold">T Shirt Printing</h4>
                          <p class="no-margin">Order details</p>
                          <br>
                        </div>
                        <div class="modal-body">
                          <div class="row form-row">
                            <div class="col-md-8">
                              <input type="text" class="form-control" placeholder="Grandsler">
                            </div>
                            <div class="col-md-4">
                              <input type="text" class="form-control" placeholder="Small">
                            </div>
                          </div>
                          <div class="row form-row">
                            <div class="col-md-12">
                              <input type="text" class="form-control" placeholder="Baranggay Barangka, Marikina City, Metro Manila, Philippines 8000">
                            </div>
                          </div>
                          <div class="row form-row">
                            <div class="col-md-6">
                              <input type="text" class="form-control" placeholder="2015-01-11">
                            </div>
                            <div class="col-md-6">
                              <input type="text" class="form-control" placeholder="₱18000">
                            </div>
                          </div>
                        </div>
                        <div class="modal-footer">
                          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                          <button type="button" class="btn btn-danger">Approve</button>
                        </div>
                      </div>
                      <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                  </div>
                  <!-- /.modal -->

1 个答案:

答案 0 :(得分:0)

如果您的所有代码都在同一个html页面上,那么您只需将此行添加到while循环中:

$ order_id = $ row [&#39; your_order_id_column&#39;];

然后为表单本身添加:

<div class="row form-row">
  <div class="col-md-12">
    <input type="text" class="form-control" value="<?php echo $order_id;?>">
  </div>
</div>

在表单代码上,主要部分是

<input type="text" name="order_id" class="form-control" value="<?php echo $order_id;?>">