Thank you Anthony. On Friday, March 8, 2013 5:47:48 PM UTC+1, Anthony wrote: > > See > http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910 > . > > On Friday, March 8, 2013 2:03:28 AM UTC-5, José Manuel López Muñoz wrote: >> >> Thank you Niphlod, >> I've do it with the Cities, but now I've to populate the "hotels" >> dropdown with the hotels available in a City. >> I want to do it with a JavaScript (Onchange), this way when a City is >> selected I can populate the hotels dropdown with the hotels available. I've >> the request (is trivial) to the data base, the hotels in a Array, but I >> don't know how to insert the values in the dropdown. >> Any clue about how to do it? :) >> >> On Thursday, March 7, 2013 4:33:35 PM UTC+1, Niphlod wrote: >>> >>> you can do as you did with the hotels (i.e. passing a queryset already >>> filtered instead of a table to the IS_IN_DB) or create a dict holding a few >>> cities with as the key the id of the city and the value the name of it. >>> >>> On Thursday, March 7, 2013 3:52:24 PM UTC+1, José Manuel López Muñoz >>> wrote: >>>> >>>> Hi, >>>> I'm trying to populate a drop down menu of a form like this: >>>> def createOffer(): >>>> hotelesUsuario=db(db.Hotel.managerID == auth.user_id) >>>> >>>> db.Offer.hotel.requires=IS_IN_DB(hotelesUsuario,'Hotel.id','%(name)s') >>>> form = SQLFORM(db.Offer) >>>> >>>> This is my Offer table: >>>> >>>> db.define_table('Offer', >>>> SQLField('created_on', 'datetime', label="D√≠a de creaci√≥n de la >>>> oferta", writable=False, default=request.now), >>>> SQLField('valid_from_date', 'datetime', label="Oferta >>>> desde el d√≠a", default = request.now), >>>> SQLField('valid_to_date', 'datetime', label="Oferta >>>> hasta el d√≠a", default = request.now), >>>> SQLField('selected','boolean', default=False, >>>> readable=False, writable=False), >>>> SQLField('city',db.City, label="Ciudad"), >>>> SQLField('hotel',db.Hotel), >>>> SQLField('num_rooms', label="N√∫mero de habitaciones", >>>> default="1"), >>>> format="%(id)s") >>>> >>>> I want to populate the DropDown menu "city" with some cities (not all >>>> the cities, like now) in my database >>>> How can I do it? >>>> form.var.city = ¿?¿? >>>> >>>> I have tried many things but is clear I don't know how to do it. >>>> >>>> Any help will be very appreciated :) >>>> >>>
-- --- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

