I'm trying to learn to use the ajax functionality and am having trouble getting it to work correctly. I am trying to use a dropdown of firms to show the related strategies. Currently this doesn't return anything to the div, but I do know that the onchange is working. It seems like the request.vars.values()[0] is not returning anything. Any help would be appreciated and also any pointers if there is a way to do this better differently. Below is my code.
I have based this on this message http://groups.google.com/group/web2py/browse_thread/thread/4a6149ddcbb768db#. <<default.py>> def test(): firms = db(db.firm).select() return dict(firms=firms) def test_chg(): firm=request.vars.values()[0] strats = db(db.firmstrat.firm_id==firm).select() options=[] for strat in strats: options.append(strat.strat_id.name) return DIV(*options).xml() <<test.html>> {{extend 'layout.html'}} {{=SELECT(_id='firmdrop', _onChange="ajax('test_chg',['firmdrop'],'target');", *[OPTION(firms[i].name,_value=str(firms[i].id)) for i in range(len(firms))] )}} <div id="target"></div> Thanks, Sam