Advertisement
Guest User

Untitled

a guest
Feb 15th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1.  
  2. <form action="delivery_add.php" method="POST" id="forms">
  3. <div class="form-group">
  4. <label>Delivery Receipt: </label>
  5. <input type="number" name="Receipt" class="form-control" />
  6. </div>
  7.  
  8. <div class="form-group">
  9. <label>Delivery Date: </label>
  10. <input type="date" name="Date" class="form-control" />
  11. </div>
  12.  
  13. <div class="form-group">
  14. <label>Supplier Name:</label>
  15. <select name="Supplier" class="form-control">
  16. <?php
  17. include('config.php');
  18. $sql = "SELECT Supplier_ID, Supplier_Name FROM tbl_supplier";
  19. $result = mysql_query($sql);
  20. while ($row = mysql_fetch_array($result)) {
  21. echo "<option value=".$row[0].">";
  22. echo $row[1];
  23. echo "</option>";
  24. }
  25. ?>
  26. </select>
  27. </div>
  28.  
  29. <a id="clickbtn" class="btn btn-default">Add Item</a>
  30. <button type="submit" class="btn btn-default">Process</button>
  31. <div class="form-group">
  32. <table class="table table-bordered table-hover"><br/>
  33. <tr>
  34. <td width="250">
  35. <label>Product Name:</label>
  36. </td>
  37. <td width="100">
  38. <label>Delivered Quantity:</label>
  39. </td>
  40. <td width="200">
  41. <label>Price:</label>
  42. </td>
  43. </tr>
  44. </table>
  45. <div id="form-sample">
  46. <table class="table table-bordered table-hover">
  47. <tr>
  48. <td width="250">
  49. <select name="Product_ID[]" class="form-connect" id="pta" onchange="myFunction(this)">;
  50. <?php
  51. $sql = "SELECT Product_ID, Product_Name FROM tbl_product";
  52. $result = mysql_query($sql);
  53. while ($row = mysql_fetch_array($result)) {
  54. echo "<option value=".$row[0].">";
  55. echo $row[1];
  56. echo "</option>";
  57. }
  58. ?>
  59. </select>
  60. </td>
  61. <td width="100">
  62. <input type="number" name="Quantity[]" placeholder="0" class="form-connect" required />
  63. </td>
  64. <td width="200">
  65. <input type="number" name="Price[]" placeholder="0.00" class="form-connect" id="prices" disabled>
  66. </td>
  67. </tr>
  68. </table>
  69. </div>
  70. </div>
  71.  
  72. </form>
  73.  
  74. <script>
  75. function myFunction(productID) {
  76. $.post(
  77. 'trial5.php',
  78. {
  79. product_id: productID
  80. },
  81. function (data) {
  82. document.getElementById('prices').value = data;
  83. }
  84. );
  85. }
  86. </script>
  87.  
  88. The code for trial5.php
  89. <?php
  90. include('config.php');
  91. $query = "SELECT Del_Price FROM tbl_product WHERE Product_ID=".$_POST['prodID'];
  92. $result = mysql_query($query)or die(mysql_error());
  93. $row = mysql_fetch_array($result);
  94.  
  95. echo "$row[0]";
  96. ?>
  97.  
  98.  
  99. The code for append:
  100.  
  101. $(document).ready(function () {
  102.  
  103. var newRow = $('#form-sample');
  104. var counter = 0;
  105. newRow.attr('id', counter);
  106.  
  107. $("#clickbtn").click(function () {
  108. $('#forms').append(newRow).html();
  109.  
  110. counter++;
  111. });
  112. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement