I wasn't able to find a simple function that would help generate a SELECT 
tag given a set of options (I did see the OPTION function) so created a 
simple one and thought it'd be useful to share. I'm new to Python so this 
may not be very elegant, but it works.

The function takes the tag's name and a dictionary of options as input, 
returns an XML formatted completed select tag.

def select_tag(name, options):
    select_tag='<select name='+name+'>'
    for key in options.keys():
        select_tag=select_tag+'<option value="'+options[key]+'">'+key+
'</option>\n'
    select_tag=select_tag+'</select>'
    
    return XML(select_tag)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to