Just for fun - paste in any controller and go to .../sql_frm_js def sql_frm_js(): t_name='any_tbl' # just for more readable because SQLFORM.factory f1_name='any_fld_1' f2_name='any_fld_2' f_id=lambda f, t=t_name: '%s_%s'%(t, f) # return id of html INPUT-element corresponding to field name btn1=BUTTON('Click me', _type="button", _onclick ="""$('#%s').val('any value') """%f_id(f1_name) ) btn2=BUTTON('And me', _type="button", _onclick ="""$('#%s').val( your_JS_fun() ) """%f_id(f1_name) )
scr=SCRIPT(""" $(document).ready(your_JS_fun_init ); function your_JS_fun_init() { $('#%s').val('Hi, I am your_JS_fun_init'); return }; function your_JS_fun() { return 'Hi, I am your_JS_fun'; }; """%f_id(f2_name) ) frm=SQLFORM.factory( Field(f1_name, 'string', comment=DIV(btn1, btn2)), Field(f2_name, 'string'), table_name=t_name) if frm.process().accepted: response.flash=frm.vars[f1_name]+','+frm.vars[f2_name] return dict(frm=frm, scr=scr) On Friday, August 14, 2015 at 3:23:17 AM UTC+3, 黄祥 wrote: > > hi, > > is it possible to pass javascript value into sqlform? > > ref: > http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation_error > > i want to know user location when create or update delivery function, yet > landing in w3schools provide it into javascript value, but don't know how > to put it on web2py sqlform. > > any idea how to pass javascript value into sqlform? > > just another idea, i think it's better to have request.geolocation in > web2py core request > > best regards, > stifan > -- 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.