Maybe use server-side DOM
parsing: http://web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing
Something like:
form.element('option', _value='value')['_selected'] = 'selected'
or:
form.element('select').update(value='value') # adding the 'value' attribute
to SELECT causes that option to be selected
Anthony
On Wednesday, September 28, 2011 7:56:34 PM UTC-4, Ed Greenberg wrote:
>
> I've tried and tried, but can't find a google search term that answers
> this.
>
> I have a FORM(), not a SQLFORM(), with a SELECT and a bunch of
> options in it, and I need to set the _selected attribute on one of
> them. When I construct the SELECT, I don't know which one needs to be
> selected until later in the controller function.
>
> Other than jQuery :), how do I tell the correct OPTION to select.
>
> I tried setting form.vars.ELEMENTNAME before returning the form, but
> no luck.
>
> I'm so sure I once knew how to do this...
>
>
>