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 <denes1...@yahoo.ca> 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 <mdipie...@cs.depaul.edu> 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 <denes1...@yahoo.ca> 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 web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.