Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(document).ready( function($)
- {
- $(function()
- {
- $('input[name=buscarPor]:radio').click(function()
- {
- if($('#descricao').attr('checked'))
- {
- $('#term').attr('class', 'descricao');
- $('#term').attr('placeholder', 'product name');
- }
- else
- {
- $('#term').attr('class', 'cod');
- $('#term').attr('placeholder', 'product code');
- }
- $('#term').focus();
- });
- });
- $('.descricao').autocomplete(
- {
- source: 'buscaDesc.php',
- minLength:2,
- // optional
- html: true,
- // optional (if other layers overlap the autocomplete list)
- open: function (event, ui)
- {
- console.log($(this).val(ui.item.label));
- return false;
- },
- select: function(event, ui)
- {
- $('#term').val(ui.item.value);
- $('form#frmBusca').submit();
- }
- });
- $('.cod').autocomplete(
- {
- source: 'buscaCod.php',
- minLength:2,
- // optional
- html: true,
- // optional (if other layers overlap the autocomplete list)
- open: function (event, ui)
- {
- console.log($(this).val(ui.item.label));
- return false;
- },
- select: function(event, ui)
- {
- $('#term').val(ui.item.value);
- $('form#frmBusca').submit();
- }
- });
- });
- </script>
- <center>
- <div style="width:400px">
- <form name="frmBusca" id="frmBusca" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
- <div>
- <label style="width:300px; font-size:14px; font-weight:bold">Search product by:</label><br><br>
- <label>Product name</label>
- <input type="radio" name="buscarPor" id="descricao" style="width:20px;" value="descricao" /><br>
- <label>Product Code</label>
- <input type="radio" name="buscarPor" id="cod" style="width:20px;" value="cod" checked /><br><br>
- <input type="text" style="width:150px;" name="term" id="term" class="cod" placeholder="Product code" value="" />
- </div>
- </form>
- </div>
- </center>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement