How can I send the id of a data to a modal?

0

This is the document from which I will send the id

    <script type="text/javascript" src="ajax/paid/ajax.js"></script>
        <script type="text/javascript">
            $(function(){
                $("#btnPaid").click();
            });
        </script>
    <?php endif; ?>
    <?php
      $fact = FacturaData::getByTipoPago();
    ?>
    <div class="row">
        <?php include("modals/rePaid.php"); ?>
        <div class="col-md-12">
            <h1>Abonos</h1>
            <div class="tab-content">
                <div id="prods" class="tab-pane fade in active">
                    <p><b>Buscar </b></p>
                    <div class="row">
                        <div class="col-md-5 col-sm-6 col-xs-10">
                            <div class="input-group">
                                <input type="text" name="product" id="busqueda" placeholder="Buscar producto" class="form-control" autofocus>
                                <span class="input-group-addon"><i class="fa fa-search fa-fw"></i>Buscar</span>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <br>
                        <div class="col-md-12">

      <?php if ($fact): ?>
        <div class="tab-content">
          <div id="process" class="tab-pane fade in active">
            <div class="clearfix"></div>

            <div class="table-responsive">
              <table class="table table-hover table-bordered">
                <thead>
                  <th></th>
                  <th>No.</th>
                  <th>Cliente</th>
                  <th>Vendedor</th>
                  <th>Fecha</th>
                  <th>Tipo De Documento</th>
                  <th>Total</th>
                </thead>
                <tbody>
                  <?php foreach ($fact as $fa): ?>

                    <?php
                      $prodsx = FacturaData::getAllSellsByFactId($fa->id); #Productos vendidos en la factura
                      $servsx = FacturaData::getAllServicesByFactId($fa->id); #Servicios vendidos en la factura
                    ?>
*AQUI ES DONDE QUIERO QUE COJA EL ID Y ME LO ENVIE AL MODAL PARA LUEGO EN EL MODAL RECIBITLO CON GET*
                      <td style="width:40px;"><a id="btnPaid" data-toggle="modal" data-target="#rePaid" class="btn btn-xs btn-default"><i class="glyphicon glyphicon-eye-open"></i></a></td>
                      <td><?php echo $fa->numerofactura; ?></td>
                      <td><?php echo $fa->getClient()->name." ".$fa->getClient()->lastname; ?></td>
                      <td><?php echo $fa->getUser()->name." ".$fa->getUser()->lastname; ?></td>
                      <td><?php echo $fa->fecha; ?></td>
                      <td><?php echo $fa->getComprobante()->nombre; ?></td>
                      <td>
                        <?php
                          $total=0;
                          foreach($prodsx as $p){
                            $prd = $p->getProduct();
                            $total += $p->cantidad * $prd->precioventa;
                          }
                          foreach ($servsx as $s) {
                            $srv = $s->getService();
                            $total += $s->cantidad * $srv->precio;
                          }
                          echo "<b>$ ".number_format($total,2,'.',',')."</b>";
                        ?>
                      </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
              </table>
            </div>
            <?php else: ?>
              <div class="clearfix"></div>
            <div class="alert alert-info">
              Vaya! No no se encontro ningun registro entre esas fechas.
            </div>
            <?php endif; ?>
          </div>

                        </div>
                    </div>
                </div>
                <div id="servs" class="tab-pane fade">
                    <p><b>Agregar servicio a la venta</b></p>
                    <br>
                    <div class="row">
                        <div class="col-md-12" id="resultado_srv">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
asked by alvin 08.12.2017 в 23:33
source

2 answers

0

What I did a couple of days ago was that by pressing the button to open the modal, that button calls a function, in the function you take the value of the id, then you can load the id into a modal field using the .value. I do not know if I explained myself very well, I hope you can understand. I'm sure there are easier ways to do it, but I do not know them. I did this in javascript, not jquery.

    
answered by 09.12.2017 в 01:18
0

The ideal is to use JQuery, when the event that launches the modal is activated, for example

$ (document) .ready {  $ ("# fieldID"). value ($ ("# id"). value ()); }

Eye! , you can use another event that throws this is just an example.!

    
answered by 09.12.2017 в 01:36