Hello,

I am trying to make a custom form with select boxes. I am using the SELECT 
helper to create the select boxes. I have a problem with setting the 
selected value. I have created the following example. 

def test_select():
    users = [('0', 'None'), 
             ('1', 'John'), 
             ('3', 'Someone Else'),
             ('2', 'Jane')
              ]
    resources = [OPTION(x[1], _value=x[0]) for x in users]
    shifts = {1:'1',2:'2',3:'3'}
    tab = TABLE()
    trow = TR()
    for row in shifts:
        trow.append(TD(SELECT(*resources,
                                 _name='name',
                                 _id='name',
                                 value=shifts[row],
                                 _style="background-color:%s;" % 'yellow')
                      )
                   )
    tab.append(trow)
    form = FORM(tab)
    return dict(form=form)

I am trying to set the value by looping through the "shifts" dictionary and 
assigning the "value" to the value from the dictionary. I expected that the 
first dropdown would be set to "John", the second to "Jane" and the 3rd to 
"Someone Else", but this is not happening. All 3 the dropdown lists are  
set to "Someone Else".

How can I assign the value of the select box properly?

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to