I added these lines in my view
<script>
jQuery(function() {
jQuery('[name=location]').focus(geolocate);
});
</script>
But it is not working.
What I am actually trying to do is while filling field 'location',it should
give the suggestions automatically fetched from google maps.
The suggestions are coming when I write this.
<input id="autocomplete" placeholder="Enter your address" onFocus="geolocate()"
type="text"></input>
What am I doing wrong??
On Tuesday, July 12, 2016 at 6:04:53 PM UTC+5:30, Massimo Di Pierro wrote:
>
> form.element(_name='location')['onfocus'] = 'geoLocation()'
>
> BUT
>
> You should really do this in the view:
>
> <script>
> jQuery(function() {
> jQuery('[name=location]').focus(geoLocation);
> });
> </script>
>
> On Tuesday, 12 July 2016 05:15:27 UTC-5, pbt wrote:
>>
>> I know how to generate input fields from form. My doubt is I want to add
>> an event 'onFocus' to that field. How to do that using SQLFORM.factory
>>
>> On Tuesday, July 12, 2016 at 2:49:30 PM UTC+5:30, Mirek Zvolský wrote:
>>>
>>> You need form and its submitting.
>>> You can use Web2py form support, see web2py.com/book chapter 7:
>>> FORM,
>>> or SQLFORM.factory (you have to save yourselves the input value after
>>> the form validation from forms.vars into db database)
>>> or SQLFORM (this will save the input value automatically)
>>>
>>> Both SQLFORM's will generate the input element, so you need learn how to
>>> modify its attributes (autofocus...) via Web2py or you can manipulate the
>>> attributes via javascript (jQuery).
>>>
>>> With FORM you define all elements in the view. So manipulating with
>>> field attributes is easy, but you have more work to do. + you need save
>>> form.vars too.
>>>
>>>
>>>
>>>
>>>
>>> Dne úterý 12. července 2016 10:43:07 UTC+2 pbt napsal(a):
>>>>
>>>> in models
>>>> db.define_table('list'
>>>> Field('name','string'),
>>>> Field('location','string')
>>>> )
>>>>
>>>> <input id="location" class="autocomplete" onFocus="geoLocation()" />
>>>> I want to store the value present in the above input field to
>>>> 'location' field in table 'list'.
>>>>
>>>>
>>>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.