You can do this way.
# Controller.py
Add id in your input field.

def test():
    form = FORM(LABEL("File(s):"), INPUT(_name='pic_upload', _type='file',
_multiple=''),
                  BR(), LABEL("Comments:"), INPUT(_name='comments'),
                  BR(), LABEL("Print Size:"), INPUT(_name='print_size'),
                  BR(), LABEL("copies:"), INPUT(_name='copies'))
    form.append(XML('<br><input list="names" name="names" id="test"><datalist
id="names"><option value="Matte"><option value="Glossy"></datalist><br>'))
    form.append(XML('<button type="submit">submit</button>'))

           return locals()

# view/test.html
Add this script in your view file.

<script>
$(document).ready(function(){
$("#test").click(function (evt) {
$("#test").val("")
});
});
</script>

Thanks
SP


On Tue, Dec 4, 2018 at 11:04 PM Arindam Dasgupta <nyn.dasgu...@gmail.com>
wrote:

> @ sandeep.
> Thanks a lot for your solution and it is working for me. But I am facing a
> small problem : When I choose a option from the drop down list and later
> change my mind and try to select a different value , I cannot do that
> because after the first selection, it is not showing other values.Any
> insight on this ? Thanks.
>
> On Tue, Dec 4, 2018 at 10:11 PM Ben Duncan <linux...@gmail.com> wrote:
>
>> Here is a sample I did when I found some OLD web2py forums. I tested with
>> a dictionary then
>> with a "in" DB ..
>> In controller/default.py:
>>
>> def company_login():
>>     # Read the company file into a dictionary
>>     company =
>> db(db.company).select(db.company.company_number,db.company.company_name,orderby=db.company.company_name)
>>
>>     # Create a form using the sets
>>     form = SQLFORM.factory(
>>         Field('username', requires=IS_NOT_EMPTY()),
>>         Field('password', 'password', requires=IS_NOT_EMPTY()),
>>         Field('Company',
>> requires=IS_IN_DB(db,db.company.company_number,'%(company_name)s')))
>> #        Field('Company', requires=IS_IN_SET(company)))
>>
>> # Note: IS_IN_SET is fugly, anyone know a way to "format" it for display?
>>
>>     if form.process().accepted:
>> #       redirect(URL('index'))
>>        response.flash = 'form accepted'
>>     elif form.errors:
>>        response.flash = T('form has errors')
>>
>>     return dict(form=form)
>>
>> In views/default/company_login.html :
>>
>> {{extend 'layout.html'}}
>> {{=form}}
>>
>>
>> -------------------------------------------------
>> Ok, my NEXT questions along this thread:
>> I need to display the values returned from the sqlform, any ideas on this
>> ?
>>
>> thanks ..
>>
>> *Ben Duncan*
>> DBA / Chief Software Architect
>> Mississippi State Supreme Court
>> Electronic Filing Division
>>
>>
>> On Tue, Dec 4, 2018 at 9:08 AM sandeep patel <patelsandeep...@gmail.com>
>> wrote:
>>
>>> @Arindam: Try the following code instead
>>>
>>> def test():
>>>     form = FORM(LABEL("File(s):"), INPUT(_name='pic_upload',
>>> _type='file', _multiple=''),
>>>                   BR(), LABEL("Comments:"), INPUT(_name='comments'),
>>>                   BR(), LABEL("Print Size:"), INPUT(_name='print_size'),
>>>                   BR(), LABEL("copies:"), INPUT(_name='copies'))
>>>     form.append(XML('<br><input list="names" name="names"><datalist
>>> id="names"><option value="Matte"><option value="Glossy"></datalist><br>'))
>>>     form.append(XML('<button type="submit">submit</button>'))
>>>
>>>     return locals()
>>>
>>> Hope this works for you
>>>
>>> Thanks
>>> SP
>>>
>>> On Tue, Dec 4, 2018 at 8:02 PM Lovedie JC <lbjc1...@gmail.com> wrote:
>>>
>>>> I have done something like that. Let me retrieve it in 3hrs
>>>>
>>>> On 4 Dec 2018 5:17 PM, "Ben Duncan" <linux...@gmail.com> wrote:
>>>>
>>>> I was working on trying to figure out the EXACT same thing !!!!!
>>>>
>>>> Thanks ..
>>>>
>>>> *Ben Duncan*
>>>> DBA / Chief Software Architect
>>>> Mississippi State Supreme Court
>>>> Electronic Filing Division
>>>>
>>>>
>>>> On Tue, Dec 4, 2018 at 6:40 AM Arindam Dasgupta <nyn.dasgu...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>> I need to display a drop down list in my form but have no idea how to
>>>>> do it. I have the following arrangements :
>>>>>
>>>>> Model :
>>>>>
>>>>> db.define_table('orders',
>>>>>
>>>>>                 Field('comments' ,type='string'),
>>>>>                 Field('print_size',requires=IS_IN_SET(['5x3.5', '6x4',
>>>>> '6x4.5', '5x7', '5x7.5', '6x8', '6x9', '12x8', '12x10',
>>>>>                '12x12', '12x15', '12x18', '12x24', '12x30',
>>>>> '12x36']),default='6x4'),
>>>>>
>>>>> Field('paper_type',requires=IS_IN_SET(['Matte','Glossy']),default='Matte'),
>>>>>                 Field('copies',requires=IS_IN_SET(mylist),default=1),
>>>>>                 Field('cart',type='boolean' ,default='False'),
>>>>>                 Field('checkout',type='boolean' ,default='False'),
>>>>>                 Field('pic_upload' ,'upload',autodelete=True),
>>>>>                 Field('order_id' , type='integer',default= 0),
>>>>>                 Field('price' , type='float' , default=1),
>>>>>                 Field('unit_price' , type='float' , default=1),
>>>>>                 Field('order_status' ,
>>>>> requires=IS_IN_SET(['Delivered','Not Delivered']) , default='Not
>>>>> Delivered'),
>>>>>
>>>>>                 auth.signature
>>>>>                 )
>>>>>
>>>>> Controller :
>>>>>
>>>>> def multiple_upload():
>>>>>   import datetime
>>>>>
>>>>>   form = FORM(LABEL("File(s):"), INPUT(_name='pic_upload',
>>>>> _type='file', _multiple=''),
>>>>>               BR(), LABEL("Comments:"), INPUT(_name='comments'),
>>>>>               BR(), LABEL("Print Size:"), INPUT(_name='print_size'),
>>>>>               BR(), LABEL("Paper Type:"),INPUT(_name='paper_type'
>>>>> ,requires=IS_IN_SET(['Matte','Glossy']) ),
>>>>>               BR(), LABEL("copies:"), INPUT(_name='copies'),
>>>>>               BR(),INPUT(_type='submit'))
>>>>>
>>>>> return dict(form=form)
>>>>>
>>>>>
>>>>> View:
>>>>>
>>>>> {{extend 'layout.html'}}
>>>>> <h1>This is the default/multiple_upload.html template</h1>
>>>>> {{=form}}
>>>>>
>>>>> In the paper type field I need to display a drop down with values
>>>>> ('Matte' , 'Glossy').
>>>>> Can you please show me how to do that.I dont want to use SQL form or
>>>>> SQLFORM.FACTORY .
>>>>> Thanks in advance for your kind suggestions.
>>>>>
>>>>> Best Regards,
>>>>> Arindam
>>>>>
>>>>> --
>>>>> 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.
>>>>>
>>>> --
>>>> 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.
>>>>
>>>>
>>>> --
>>>> 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.
>>>>
>>> --
>>> 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.
>>>
>> --
>> 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.
>>
> --
> 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.
>

-- 
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.

Reply via email to