Thanks Leonel and Ian. Just in case it might help someone else, this is the code in layout.html that works for me:
<div class="collapse navbar-collapse navbar-ex1-collapse"> {{if response.menu:}} {{=MENU(response.menu, _class='nav navbar-nav',li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} <ul class="nav navbar-nav"> {{='auth' in globals() and auth.navbar('Welcome',mode='dropdown') or ''}} </ul> <ul class="nav navbar-nav navbar-right"> </br> <!-- Global Search --> <style> #suggestions { position: relative; } .suggestions { background: lightblue; border: solid 1px #55A6C8; } .suggestions DIV { padding: 2px 4px 2px 4px; } </style> <form class="form-inline global-search" action="{{=URL('wos', 'globalsearch')}}"> <div class="form-group"> <input type="text" id="word" name="word" style="background-color:lightblue; color:blue;" placeholder="Search for ..." /> </div> <button type="submit" id="s" class="btn btn-info" > <span class="glyphicon glyphicon-search"></span> </button> </br> <a href="#" style="color:lightgray;">Advanced search</a> <div style="position: relative;" id="suggestions" class="suggestions"></div> </form> </ul> </div> and at the bottom of the file in a <script> environment: jQuery("#word").keyup(function(){ ajax('{{=URL('default', 'wordlookup')}}', ['word'], 'suggestions')}); Regards Johann On 18 November 2015 at 16:31, Ian Ryder <i.ry...@appichar.com.au> wrote: > It could be pretty straight forward - as Leonel says, you would use > Javascript / Ajax. If you rolled your own autocomplete you would have a > controller in default (for example) and the layout would refer back to that > controller. Doesn't matter what page you are looking at, the Ajax call is > always back to the 'default' controller. > > Have a look at the jQuery / Ajax section of the book: > http://web2py.com/books/default/chapter/29/11/jquery-and-ajax > > There's even a built-in autocomplete in web2py which might suit: > http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#Auto-completion > > > On Wednesday, 18 November 2015 09:40:26 UTC+1, Johann Spies wrote: >> >> As I understand Web2py forms in views are managed by controllers. >> >> I want to use a search form in the menubar like the attached image. >> >> [image: Inline images 1] >> >> This form is presented by layout.html. >> >> I want the form to be an auto-complete widget with sql-lookups in the >> background. >> >> So from where do I control that form? From a model? >> >> The form must be available from all parts of the app. I do not want to >> add code in every controller to manage it. >> >> Regards >> Johann >> -- >> Because experiencing your loyal love is better than life itself, >> my lips will praise you. (Psalm 63:3) >> > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.