That worked (with index [0]).
Now I can populate a drop down list in a FORM (vs. SQLFORM) from data
in a database. Not sure if this is the 'best' way to do it, but it
works.
rows=db(db.colortable.color!=None).select() #query the database
optionlist=[str(c[0]) for c in rows.response] #convert query result
from SQLRows object to list
form=FORM(TABLE(TR("Color:",SELECT(optionlist, _name="color")))) #use
list as SELECT parameter
return dict(form=form,vars=form.vars)
Thanks for the assist.
On Feb 24, 4:11 pm, DenesL <[email protected]> wrote:
> colorlist=[ c[1] for c in rows.response ]
> or
> colorlist=[ str(c[1]) for c in rows.response ]
> if you don't want encoding.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---