Guest User

Untitled

a guest
Feb 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. //index.php
  2. <script type="text/javascript">
  3. $(document).ready(function()
  4. {
  5. $(".autodoc").change(function()
  6. {
  7. var id=$(this).val();
  8. var dataString = 'id='+ id;
  9. $.ajax
  10. ({
  11. type: "POST",
  12. url: "ajax_price.php",
  13. data: dataString,
  14. cache: false,
  15. success: function(html)
  16. {
  17. $(".pay").html(html);
  18. }
  19. });
  20. });
  21. });
  22. </script>
  23. .
  24. .
  25. <form action="bill_submit.php" method="POST" id="bbe">
  26. <input type="text" name="name" id="textfield2" class="input-xlarge" data-rule-required="true" data-rule-minlength="1" placeholder="Name" maxlength="30">
  27. <input type="text" name="med" id="keyword" tabindex="0" class="autodoc">
  28. .
  29. .
  30. </form>
  31.  
  32. //ajax_price.php
  33.  
  34. <?php
  35. include('db_conn.php');
  36.  
  37. if ($_POST['id']) {
  38. $id = $_POST['id'];
  39. $query = "select * from pharma where name='$id' ";
  40. //echo $query;
  41. $result = mysqli_query($con, $query);
  42.  
  43. if (mysqli_affected_rows($con) != 0) {
  44. while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
  45. echo "<input class='txt' type='text' value ='" . $row['per_unit_price'] . "' name='txt' id='fbname' readonly/>";
  46.  
  47. }
  48.  
  49. } else {
  50. echo "<input class='txt' type='text' value ='$name' name='txt' id='fbname' readonly/>";
  51. }
  52.  
  53. }
  54. ?>
Add Comment
Please, Sign In to add comment