Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. <div class="container">
  2. <h2>Modal</h2>
  3. <!-- Trigger the modal with a button -->
  4. <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Unidade</button>
  5. <input type="text" class="form-control unidade-input" name="unidade" id="tr">
  6. <!-- Modal -->
  7. <div class="modal fade" id="myModal" role="dialog">
  8. <div class="modal-dialog">
  9.  
  10. <!-- Modal content-->
  11. <div class="modal-content">
  12. <div class="modal-header">
  13. <button type="button" class="close" data-dismiss="modal">&times;</button>
  14. <label class="modal-title">Unidade</label>
  15.  
  16. </div>
  17. <div class="modal-body">
  18. <table id="tr">
  19. <?php
  20. include ("conn.php");
  21.  
  22. echo "<table border = 1>";
  23. echo "<tr>";
  24. echo "<th>Unidade</th>";
  25. echo "<th>Descrição</th>";
  26. echo "</tr>";
  27.  
  28. $result = "SELECT codigo, descricao FROM cadunid";
  29. $resultado = mysqli_query($conn, $result);
  30.  
  31. while($row = mysqli_fetch_assoc($resultado)) {
  32. echo"</tr>";
  33. echo "<td>". $row['codigo'] ."</td>";
  34. echo "<td>". $row['descricao'] ."</td>";
  35. echo "</tr>";
  36. }
  37. ?>
  38. </table>
  39. </div>
  40. <div class="modal-footer">
  41. <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
  42. </div>
  43. </div>
  44.  
  45. </div>
  46. </div>
  47. </div>
  48.  
  49. <script>
  50. $(document).on('click', 'table', function() {
  51. var value = $(this).val(tr);
  52. $('.close').trigger('click');
  53. $('.unidade-input').val(value);
  54. });
  55. </script>
  56.  
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement