If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

Include the necessary files by adding this to your model or controller.


Add the widget in db.py

def slider_widget(f,v):
    wrapper = DIV(_id="slider_wrapper",_style="width: 200px;text-align:center;")
    inp = SQLFORM.widgets.string.widget(f,v)
    sld = DIV(_id='slider_' + inp['_id'])
    sldval = SPAN(inp['_value'],_id=sld['_id']+'_val')
    scr1 = "jQuery('#%s').hide();" % inp['_id']
    scr2 = "jQuery('#%s').val(ui.value);jQuery('#%s').text(ui.value);" % (inp['_id'], sldval['_id'])
    jqscr = SCRIPT(scr1,"jQuery('#%s').slider({value: '%s',stop: function(event, ui) {%s}});" % \
    return wrapper

Create a test table and set the widget to our new slider widget


Create a form in your controller

def index():
    form = SQLFORM(db.test)    
    if form.accepts(request.vars,session):
        response.flash = "Got it"
    all = db().select(db.test.ALL)
    return dict(form=form,all=all)


Demo application (right click/Save As): Download

Related slices

Comments (0)

Hosting graciously provided by:
Python Anywhere