If the options are in list or tuple, than for practical consequences, they are set in stone and there is no way you can allow a user to add one. Unless, as Denes suggest, you use the list to make the dropdown but you do not use the validator to validated.
On Jan 22, 10:47 pm, NeonGoby <[email protected]> wrote: > The select options are defined by requires=IS_IN_SET(), so might need > a means to update the set defined for this table field. > > On Jan 22, 11:25 am, DenesL <[email protected]> wrote: > > > Nice code but what I meant to say is that allowing the user to add a > > new option is basically the same as saying accept anything but empty > > (unless you have a list of all fruits somewhere). > > Just changing the validator to IS_NOT_EMPTY would do. > > > On Jan 22, 2:02 pm, mdipierro <[email protected]> wrote: > > > > something like this? > > > > <script> > > > jQuery(document).ready(function(){ > > > jQuery('#mySelect').change(function(){ > > > if(jQuery('#mySelect').val()=='Specify...') > > > var newoption = prompt("Your choice:",""); > > > var d = jQuery.json({url:'{{=URL > > > (r=request,f='register_new_option')}}',data:'option='+escape > > > (newoption)}); > > > if(d['id']) > > > jQuery('#mySelect').prepend('<option>' + newoption + '</ > > > option>'); > > > else alert(d['error']); > > > }); > > > > }); > > > > and create a new action in default.py > > > > @auth.requires_login() > > > def register_new_option(): > > > from serializer import json > > > (value,error) = db.optiontable.optionvalue.requires > > > (request.vars.option) > > > if not error: > > > return json(dict(id=db.optiontable.insert(optionvalue=value) > > > else: > > > return json(dict(id=0,error=error)) > > > > On Jan 22, 12:31 pm, DenesL <[email protected]> wrote: > > > > > How would you validate the field?. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" 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.

