Hi,
I have a table with Offers that belongs to hotels that belongs to Cities .
Now I have a SQLFORM that help me to create new offers and I want to make a
cascading drop down list for all the hotels in a City when a City is
created.
I have found the way that Massimo recommends:
jQuery(function(){
jQuery('#id_first_dropdown').change(function(){
var selection = jQuery('#id_first_dropdown').val();
jQuery.post('{{=URL('callbak')}}','value='+escapeURIComponent(
selection)).success(function(data){
jQuery('#id_second_dropdown').html(data);
});
});
});
Although I barely understand the code (I'm very new with this), I don't
know how to reference to a list drop down that is returned in the SQLFORM.
To clarify the question this is my database model:
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,
writable=False),
SQLField('name', writable=False, default=request.now),
SQLField('city',db.City, label="Ciudad"),
SQLField('hotel',db.Hotel),
format="%(id)s")
And I what to make a createOffer form with a drop down list of Cities that
populate a Hotels drop down with the hotels that belongs to that City.
I'm returning 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)
return dict(form=form, db = db)
Thank you very much for your help
--
---
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.