Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A few people have asked how to add multiple form fields and search to separate databases.
- You can create 2 search files checking different databases/tables etc.
- so search.php and search2.php
- Then put this into the head of the page you have your form on replacing the "name of person" with what ever the name of 1 of your form field is and do the same for "city" to what ever other form field you want to search for.
- <script>
- $(document).ready(function(){
- $('input.nameofperson').typeahead({
- name: 'nameofperson',
- remote:'search.php?key=%QUERY',
- limit : 10
- });
- $('input.city').typeahead({
- name: 'city',
- remote:'search2.php?key=%QUERY',
- limit : 10
- });
- });
- </script>
- now make sure that the "name" and the "class" for each form field match 1 of the above.
- <input type="text" name="nameofperson" class="nameofperson tt-query" autocomplete="off" spellcheck="false" placeholder="Type name of person">
- and for the second field:
- <input type="text" name="city" class="city tt-query" autocomplete="off" spellcheck="false" placeholder="Type name of person">
- Hope this helps and makes sense to anyone :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement