Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. $(document).ready( function($)
  4. {
  5.  
  6. $(function()
  7. {
  8. $('input[name=buscarPor]:radio').click(function()
  9. {
  10. if($('#descricao').attr('checked'))
  11. {
  12. $('#term').attr('class', 'descricao');
  13. $('#term').attr('placeholder', 'product name');
  14. }
  15. else
  16. {
  17. $('#term').attr('class', 'cod');
  18. $('#term').attr('placeholder', 'product code');
  19. }
  20. $('#term').focus();
  21. });
  22. });
  23.  
  24. $('.descricao').autocomplete(
  25. {
  26. source: 'buscaDesc.php',
  27. minLength:2,
  28. // optional
  29. html: true,
  30. // optional (if other layers overlap the autocomplete list)
  31. open: function (event, ui)
  32. {
  33. console.log($(this).val(ui.item.label));
  34.  
  35. return false;
  36. },
  37. select: function(event, ui)
  38. {
  39. $('#term').val(ui.item.value);
  40. $('form#frmBusca').submit();
  41. }
  42. });
  43.  
  44. $('.cod').autocomplete(
  45. {
  46. source: 'buscaCod.php',
  47. minLength:2,
  48. // optional
  49. html: true,
  50. // optional (if other layers overlap the autocomplete list)
  51. open: function (event, ui)
  52. {
  53. console.log($(this).val(ui.item.label));
  54.  
  55. return false;
  56. },
  57. select: function(event, ui)
  58. {
  59. $('#term').val(ui.item.value);
  60. $('form#frmBusca').submit();
  61. }
  62. });
  63. });
  64.  
  65. </script>
  66.  
  67. <center>
  68.  
  69. <div style="width:400px">
  70. <form name="frmBusca" id="frmBusca" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  71.  
  72. <div>
  73. <label style="width:300px; font-size:14px; font-weight:bold">Search product by:</label><br><br>
  74.  
  75. <label>Product name</label>
  76. <input type="radio" name="buscarPor" id="descricao" style="width:20px;" value="descricao" /><br>
  77.  
  78. <label>Product Code</label>&nbsp;&nbsp;
  79. <input type="radio" name="buscarPor" id="cod" style="width:20px;" value="cod" checked /><br><br>
  80.  
  81. <input type="text" style="width:150px;" name="term" id="term" class="cod" placeholder="Product code" value="" />
  82. </div>
  83. </form>
  84. </div>
  85.  
  86. </center>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement