Ajax will help you.

You need to load countries HTML OPTION's when continent changes.



On Wed, Jan 2, 2013 at 3:26 AM, Calvin <[email protected]> wrote:
> Say I have a look-up tables as follows:
>
> db.define_table('continent',
>    Field('name')
> )
>
>
> db.define_table('country',
>    Field('name'),
>    Field('in_continent', db.continent, requi)
> )
>
> Now, if I then have a table as defined:
>
>
>
> I would then like to have an SQLFORM in which field country presents a list
> in an options dropdown box with only countries based on what continent is
> selected in the record but I am not able to figure out the correct syntax.
>
>
> db.define_table('where_is_carmen',
>   Field('continent', db.continent, default= 1, requires = IS_IN_DB(db,
> 'continent.id', '%(name)s'), represent = lambda value, row:
> db.continent[value].name),
>   Field('country', db.country, requires = lambda id:
> IS_EMPTY_OR(IS_IN_DB(db(db.country.continent==(db.where_is_carmen[id].continent
> if id else db.where_is_carmen.continent.default)), 'country.id',
> '%(name)s')))
> )
>
>
> I would then like to have an SQLFORM in which field country presents a list
> in an options dropdown box with only countries based on what continent is
> selected in the record but I am not able to figure out the correct syntax.
>
> Any light shed on how this could be done would be much appreciated.
>
> --
>
>
>

-- 



Reply via email to