I suggest change the getproduct to return JSON and change the view to use the .getJSON instead of ajax function. http://docs.jquery.com/Ajax/jQuery.getJSON
So you can have an action triggered when data is received. Massimo On Aug 3, 11:13 am, Sophie <kfarron...@gmail.com> wrote: > Hi > > i have a problem with a combo. I have 3 tables "productType","product" > and "sales". So when i select a "productType" it appears a combo with > the products of that type. My problem is when i want to select a > product and i want the sales of that product. > > Here is my code: > > Controller: > def index(): > productType = db().select(db.productType.ALL) > return dict(productType=productType) > > def getproduct(): > productType = request.vars.values()[0] > product = db(db.product.productTypeId == productType).select() > return SELECT(_id='product',*[OPTION(product[i].nProduct, > _value=str(product[i].id)) for i in range(len(product))]) > > -->Here, i think i have to return 2 values, the combo and the product. > But i dont know how to return both values. > -->The other problem is where i have insert the ajax, so when i do the > onChange it redirects to getsales. > > def getsales(): > product = request.vars.values()[0] > sales = db(db.sales.productId == product).select() > return SELECT(_id='sales',*[OPTION(sales[i].nSales, _value=str > (sales[i].id)) for i in range(len(sales))]) > > -->What changes i have to do in the view. > > View: > {{extend 'layout.html'}} > <table> > <tr> > {{=SELECT( _id='productType', _onChange="ajax('"+URL > (r=request,f='getproduct')+"' > , ['productType'], 'target');", *[OPTION(productType > [i].nProductType,_value=str(productType[i].id)) for i in range(len > (productType))] )}} > </tr> > <tr> > <div id="target"> <div> > </tr> > </table> > > -->I think another way to do it. but i dont know if this is posible. > Create the combo in the view, and when i select a productType, i want > to execute a function in the controller wich receive the > productTypeId, i do a select and the other combo appear with the > data. > > I hope you can help me. Thanks a lot. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---