I'm building a cascading dropdown lists. I use web2py ajax function to do
it. My code:
select 1 (parent):
<select class="generic-widget" id="seafarer_experience_department"
name="department"
onchange="jQuery('#seafarer_experience_rank__row').show('fast');ajax('rank',
['department'], 'seafarer_experience_rank');">
{{=OPTION('-- Choose department --', _value="")}}
{{for d in departments:}}
{{=OPTION(d.name, _value=d.id)}}
{{pass}}
</select>
select 2 (child):
<select class="generic-widget" id="seafarer_experience_rank" name="rank">
{{if request.vars.department:}}
{{for r in ranks:}}
{{=OPTION(r.name, _value=r.id)}}
{{pass}}
{{pass}}
</select>
controller function:
def rank():
ranks = db(db.rank.department_id ==
request.vars.department).select(db.rank.id, db.rank.name,
orderby=db.rank.name)
return ranks
Ajax function calls *rank *function and passess value of the currently
selected option in *department *select (parent). Then, the function assigns
DAL query to *ranks *and returns it.
The thing is that *ranks *is a string when returned. My for loop in the
select 2 is ommited and the its example result code looks like this:
<select class="generic-widget" id="seafarer_experience_rank" name="rank">
"rank.idrank.name137Chief Cook138Chief Steward139Cook
Assistant140Messman136Second Cook141Steward"
</select>
So it LOOKS like a Row object but it's a string obvioulsy - and so I can't
get any Row data out of it (r.name, r.id).
Begging for help her :)
--
---
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.