On Wed, May 27, 2009 at 1:19 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> Try
>
> <form onSubmit="ajax('{{=URL(r=request,f='search')}}',
> ['q'],'target');">
> <INPUT type="text" id='q' value=""/>
> <INPUT type="submit" value="submit" />
> </form>

Thanks for the prompt suggestion, but it does not work.
With this code, both Enter key and submit button have the same bad
behavior: they just run a GET of the same current URL ("searchform"),
without passing parameters...

Other idea?




>
> On May 27, 4:03 am, Vincent Borghi <vincent.borgh...@gmail.com> wrote:
>> Hello,
>>
>> In the following form (essentially taken from web2py examples),
>> the "Enter" key does not work as expected, I am obliged
>> to click on the submit button.
>>
>> === test1/views/default/searchform.html ===
>> {{extend 'layout.html'}}
>> <p>Type something and press the button.</p>
>> <form>
>> <INPUT type="text" id='q' value=""/>
>> <INPUT type="button" value="submit"
>> onclick="ajax('{{=URL(r=request,f='search')}}',['q'],'target');"/>
>> </form>
>> <br/>
>> <div id="target"></div>
>>
>> === test1/controllers/default.py ===
>> #[...]
>> def searchform():
>>     return dict()
>> #
>> def search():
>>     chars = ""
>>     if request.vars.q:
>>         chars = request.vars.q     # (to do: sanitize chars)
>>     rows = 
>> db(db.contact.site_code.like('%'+chars+'%')|db.contact.customer_rsa.like('%'+chars+'%')).select()
>>     return SQLTABLE(rows, truncate=48)
>>
>> ==========================
>>
>> In myhttp://127.0.0.1:8000/test1/default/searchformpage,
>> once the input field is filled with something, then:
>> - if I press enter, my browser (Firefox 3) apparently does
>>   a GET of the same current URL ("searchform"), without passing parameters.
>>   This is not what i expect.
>> - if I click on the submit button, i obtain the expected behavior,
>>   i.e. the browser does a "POST /test1/default/search" passing
>>  appropriately the "q=xxx" param.
>>
>> How to obtain the same behavior whether the user hits Enter or he
>> clicks Submit?
>>
>> Thanks
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to