On Tuesday, June 30, 2015 at 2:55:20 PM UTC-4, D. Kev wrote: > > I wanna use OnKeyPress to call a javascript, but I'm using a SQLForm, What > can I do? >
Field('myfield', widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, _onkeypress='myJsFunction();')) (See http://web2py.com/books/default/chapter/29/07/forms-and-validators#Widgets.) Or: form = SQLFORM(db.mytable) form.element('input[name=myfield]').update(_onkeypress='myJsFunction();') (See http://web2py.com/books/default/chapter/29/05/the-views#elements.) The first will affect all SQLFORMs based on this DAL table, and the second will only affect this specific form. Anthony -- 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/d/optout.