Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="container">
- <h2>Modal</h2>
- <!-- Trigger the modal with a button -->
- <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Unidade</button>
- <input type="text" class="form-control unidade-input" name="unidade" id="tr">
- <!-- Modal -->
- <div class="modal fade" id="myModal" role="dialog">
- <div class="modal-dialog">
- <!-- Modal content-->
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal">×</button>
- <label class="modal-title">Unidade</label>
- </div>
- <div class="modal-body">
- <table id="tr">
- <?php
- include ("conn.php");
- echo "<table border = 1>";
- echo "<tr>";
- echo "<th>Unidade</th>";
- echo "<th>Descrição</th>";
- echo "</tr>";
- $result = "SELECT codigo, descricao FROM cadunid";
- $resultado = mysqli_query($conn, $result);
- while($row = mysqli_fetch_assoc($resultado)) {
- echo"</tr>";
- echo "<td>". $row['codigo'] ."</td>";
- echo "<td>". $row['descricao'] ."</td>";
- echo "</tr>";
- }
- ?>
- </table>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- $(document).on('click', 'table', function() {
- var value = $(this).val(tr);
- $('.close').trigger('click');
- $('.unidade-input').val(value);
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement