I have the following function:

def index():
    form=SQLFORM.factory(
        Field('word',length=128,requires=IS_NOT_EMPTY()),
 
Field('locality',length=64,requires=IS_NOT_EMPTY()),separator=False)
    rows=[]
    if form.accepts(request.vars,session,keepvalues=True):
        rows=db().select()
    elif form.errors:
        response.flash=response.flash_searcherror
    else:
        response.flash=response.flash_searchform
    return dict(form=form,rows=rows)


Field 'word' should be a multiselect, Field 'locality' an
autocomplete:

def keywords_multiselect():
    rows=db(db.NetworkKeyword.networkID==session.hubnetworkID)\
    
.select(db.NetworkKeyword.word,distinct=True,orderby=db.NetworkKeyword.word).as_list()
    result=[r['word']for r in rows]
    return response.json(result)

def locality_autocomplete():
 
rows=db((db.NodeKeyword.word==???)&(db.NodeKeyword.nodeID==db.Address.nodeID)&
\
    (db.Address.locality.like(request.vars.term+'%')))\
    
.select(db.Address.locality,distinct=True,orderby=db.Address.locality).as_list()
    result=[r['locality']for r in rows]
    return response.json(result)


In the view I have the following code:

<script type="text/javascript">
$(document).ready(function(){
   $("#word").multiselect();
});

$(function() {
  $("#no_table_locality").autocomplete({
    source: "{{=URL('hubaddressbook', 'locality_autocomplete')}}",
    minLength: 2
  });
});
</script>


I had a look at the list:reference example in chapter 6 of the book to
get the options for the multiselect, however, in my case the options
are the result of a query. How do I get the result of
keywords_multiselect(): function in the word Field multiselect?

When the user selects a word, that word should replace the ??? in the
locality_autocomplete(): function. How would I get that to work?


Kind regards,

Annet.

Reply via email to