How to use the html.OPTION function in html

To help you get started, we’ve selected a few html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github web2py / pydal / gluon / sqlhtml.py View on Github external
if csv and nrows:
            #search_actions.append(gridbutton(
            #        buttonclass='buttonexport',
            #        buttontext='Export',
            #        trap = False,
            #        buttonurl=url(args=['csv'],
            #                      vars=dict(keywords=request.vars.keywords or ''))))

        #================================================================
            options =[]
            for k,v in sorted(exportManager.items()):
                if hasattr(v, "__getitem__"):
                    label = v[1]
                else:
                    label = k
                options.append(OPTION(T(label),_value=k))
            ##FIXME ?
            mysignature = url(args=['export']).split('?', 1)
            mysignature = psq(mysignature[-1]).get('_signature', [None])[-1]
            f = FORM(BUTTON(SPAN(_class=ui.get('buttonexport')),
                            "Export", _type="submit", _class=ui.get('button')),
                     SELECT(options, _name="export_type"),
                     INPUT(_type="hidden", _name="order",
                           _value=request.vars.order),
                     INPUT(_type="hidden", _name="_signature",
                            _value=mysignature),
                     INPUT(_type="hidden", _name="keywords",
                           _value=request.vars.keywords or ''),
                     _method="GET", _action=url(args=['export']))
            search_actions.append(f)

        #================================================================
github web2py / web2py / gluon / sqlhtml.py View on Github external
if csv and nrows:
            #search_actions.append(gridbutton(
            #        buttonclass='buttonexport',
            #        buttontext='Export',
            #        trap = False,
            #        buttonurl=url(args=['csv'],
            #                      vars=dict(keywords=request.vars.keywords or ''))))

        #================================================================
            options =[]
            for k,v in sorted(exportManager.items()):
                if hasattr(v, "__getitem__"):
                    label = v[1]
                else:
                    label = k
                options.append(OPTION(T(label),_value=k))
            ##FIXME ?
            mysignature = url(args=['export']).split('?', 1)
            mysignature = psq(mysignature[-1]).get('_signature', [None])[-1]
            f = FORM(BUTTON(SPAN(_class=ui.get('buttonexport')),
                            "Export", _type="submit", _class=ui.get('button')),
                     SELECT(options, _name="export_type"),
                     INPUT(_type="hidden", _name="order",
                           _value=request.vars.order),
                     INPUT(_type="hidden", _name="_signature",
                            _value=mysignature),
                     INPUT(_type="hidden", _name="keywords",
                           _value=request.vars.keywords or ''),
                     _method="GET", _action=url(args=['export']))
            search_actions.append(f)

        #================================================================
github web2py / web2py / gluon / sqlhtml.py View on Github external
else:
                    value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
                new_button = INPUT(_type="button", _value=T('New'),
                                  _onclick="w2p_build_query('new','"+str(field)+"')")
                and_button = INPUT(_type="button", _value=T('And'),
                                   _onclick="w2p_build_query('and','"+str(field)+"')")
                or_button = INPUT(_type="button", _value=T('Or'),
                                  _onclick="w2p_build_query('or','"+str(field)+"')")

                criterion.extend([operators,value_input,new_button,and_button,or_button])
            criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
                                _class='w2p_query_row hidden'))
        criteria.insert(0,SELECT(
                _id="w2p_query_fields",
                _onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",
                *[OPTION(label, _value=fname) for fname,label in selectfields]))
        fadd = SCRIPT("""
        jQuery('#w2p_query_panel input,#w2p_query_panel select').css(
               'width','auto').css('float','left');
        jQuery(function(){web2py_ajax_fields('#w2p_query_panel');});
        function w2p_build_query(aggregator,a){
          var b=a.replace('.','-');
          var option = jQuery('#w2p_field_'+b+' select').val();
          var value = jQuery('#w2p_value_'+b).val().replace('"','\\\\"');
          var s=a+' '+option+' "'+value+'"';
          var k=jQuery('#web2py_keywords');
          var v=k.val();
          if(aggregator=='new') k.val(s); else k.val((v?(v+' '+ aggregator +' '):'')+s);
          jQuery('#w2p_query_panel').slideUp();
        }
        """)
        return (INPUT(
github spiffytech / MobileBlur / gluon / sqlhtml.py View on Github external
else:
                    value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
                new_button = INPUT(_type="button", _value=T('New'),
                                  _onclick="w2p_build_query('new','"+str(field)+"')")
                and_button = INPUT(_type="button", _value=T('And'),
                                   _onclick="w2p_build_query('and','"+str(field)+"')")
                or_button = INPUT(_type="button", _value=T('Or'),
                                  _onclick="w2p_build_query('or','"+str(field)+"')")

                criterion.extend([operators,value_input,new_button,and_button,or_button])
            criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
                                _class='w2p_query_row hidden'))
        criteria.insert(0,SELECT(
                _id="w2p_query_fields",
                _onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",
                *[OPTION(label, _value=fname) for fname,label in selectfields]))
        fadd = SCRIPT("""
        jQuery('#w2p_query_panel input,#w2p_query_panel select').css(
               'width','auto').css('float','left');
        jQuery(function(){web2py_ajax_fields('#w2p_query_panel');});
        function w2p_build_query(aggregator,a){
          var b=a.replace('.','-');
          var option = jQuery('#w2p_field_'+b+' select').val();
          var value = jQuery('#w2p_value_'+b).val().replace('"','\\\\"');
          var s=a+' '+option+' "'+value+'"';
          var k=jQuery('#web2py_keywords');
          var v=k.val();
          if(aggregator=='new') k.val(s); else k.val((v?(v+' '+ aggregator +' '):'')+s);
          jQuery('#w2p_query_panel').slideUp();          
        }      
        """)
        return CAT(
github web2py / pydal / gluon / sqlhtml.py View on Github external
else:
                    value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
                new_button = INPUT(_type="button", _value=T('New'),
                                  _onclick="w2p_build_query('new','"+str(field)+"')")
                and_button = INPUT(_type="button", _value=T('And'),
                                   _onclick="w2p_build_query('and','"+str(field)+"')")
                or_button = INPUT(_type="button", _value=T('Or'),
                                  _onclick="w2p_build_query('or','"+str(field)+"')")

                criterion.extend([operators,value_input,new_button,and_button,or_button])
            criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
                                _class='w2p_query_row hidden'))
        criteria.insert(0,SELECT(
                _id="w2p_query_fields",
                _onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",
                *[OPTION(label, _value=fname) for fname,label in selectfields]))
        fadd = SCRIPT("""
        jQuery('#w2p_query_panel input,#w2p_query_panel select').css(
               'width','auto').css('float','left');
        jQuery(function(){web2py_ajax_fields('#w2p_query_panel');});
        function w2p_build_query(aggregator,a){
          var b=a.replace('.','-');
          var option = jQuery('#w2p_field_'+b+' select').val();
          var value = jQuery('#w2p_value_'+b).val().replace('"','\\\\"');
          var s=a+' '+option+' "'+value+'"';
          var k=jQuery('#web2py_keywords');
          var v=k.val();
          if(aggregator=='new') k.val(s); else k.val((v?(v+' '+ aggregator +' '):'')+s);
          jQuery('#w2p_query_panel').slideUp();
        }
        """)
        return (INPUT(
github jyr / MNPP / Library / python26 / lib / python2.6 / site-packages / gluon / sqlhtml.py View on Github external
def callback(self):
        if self.keyword in self.request.vars:
            field = self.fields[0]
            rows = self.db(field.like(self.request.vars[self.keyword]+'%'))\
                .select(orderby=self.orderby,limitby=self.limitby,*self.fields)
            if rows:
                if self.is_reference:
                    id_field = self.fields[1]
                    raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
                                          _size=len(rows),_multiple=(len(rows)==1),
                                          *[OPTION(s[field.name],_value=s[id_field.name],
                                                   _selected=(k==0)) \
                                                for k,s in enumerate(rows)]).xml())
                else:
                    raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
                                          _size=len(rows),_multiple=(len(rows)==1),
                                          *[OPTION(s[field.name],
                                                   _selected=(k==0)) \
                                                for k,s in enumerate(rows)]).xml())
            else:

                raise HTTP(200,'')
    def __call__(self,field,value,**attributes):
github jyr / MNPP / Library / python26 / lib / python2.6 / site-packages / gluon / sqlhtml.py View on Github external
if self.keyword in self.request.vars:
            field = self.fields[0]
            rows = self.db(field.like(self.request.vars[self.keyword]+'%'))\
                .select(orderby=self.orderby,limitby=self.limitby,*self.fields)
            if rows:
                if self.is_reference:
                    id_field = self.fields[1]
                    raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
                                          _size=len(rows),_multiple=(len(rows)==1),
                                          *[OPTION(s[field.name],_value=s[id_field.name],
                                                   _selected=(k==0)) \
                                                for k,s in enumerate(rows)]).xml())
                else:
                    raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
                                          _size=len(rows),_multiple=(len(rows)==1),
                                          *[OPTION(s[field.name],
                                                   _selected=(k==0)) \
                                                for k,s in enumerate(rows)]).xml())
            else:

                raise HTTP(200,'')
    def __call__(self,field,value,**attributes):
github web2py / web2py / gluon / sqlhtml.py View on Github external
if rows:
                if self.is_reference:
                    id_field = self.fields[1]
                    if self.help_fields:
                        options = [OPTION(self.help_string % dict([(h.name,s[h.name]) for h in self.fields[:1]+self.help_fields]),
                                          _value=s[id_field.name], _selected=(k==0)) for k,s in enumerate(rows)]
                    else:
                        options = [OPTION(s[field.name],_value=s[id_field.name],
                                          _selected=(k==0)) for k,s in enumerate(rows)]
                    raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
                                          _size=len(rows),_multiple=(len(rows)==1),
                                          *options).xml())
                else:
                    raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
                                          _size=len(rows),_multiple=(len(rows)==1),
                                          *[OPTION(s[field.name],
                                                   _selected=(k==0)) \
                                                for k,s in enumerate(rows)]).xml())
            else:
                raise HTTP(200,'')
github web2py / web2py / gluon / sqlhtml.py View on Github external
if fields[0]._db._adapter.dbengine=='google:datastore':
            search_options['string'] = ['=','!=','<','>','<=','>=']
            search_options['text'] = ['=','!=','<','>','<=','>=']
        criteria = []
        selectfields = []
        for field in fields:
            name = str(field).replace('.','-')
            criterion = []
            options = search_options.get(field.type,None)
            if options:
                label = isinstance(field.label,str) and T(field.label) or field.label
                selectfields.append((str(field),label))
                operators = SELECT(*[T(option) for option in options])
                if field.type=='boolean':
                    value_input = SELECT(
                        OPTION(T("True"),_value="T"),OPTION(T("False"),_value="F"),
                        _id="w2p_value_"+name)
                else:
                    value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
                new_button = INPUT(_type="button", _value=T('New'),
                                  _onclick="w2p_build_query('new','"+str(field)+"')")
                and_button = INPUT(_type="button", _value=T('And'),
                                   _onclick="w2p_build_query('and','"+str(field)+"')")
                or_button = INPUT(_type="button", _value=T('Or'),
                                  _onclick="w2p_build_query('or','"+str(field)+"')")

                criterion.extend([operators,value_input,new_button,and_button,or_button])
            criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
                                _class='w2p_query_row hidden'))
        criteria.insert(0,SELECT(
                _id="w2p_query_fields",
                _onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",