Perfect, just what I was searching for. I knew there was a way to do
this with js, just didn't know the keyword event.keyCode to search on.
Thanks.

-Steve

On 6/11/05, Slawek <[EMAIL PROTECTED]> wrote:
> i have answered You yesterday but i cant see my mail, so i do it again...
> sht strange is going on in my new mail client so im sory if someone was
> spamed by this mail:P
> 
> 
> 
> 
> the idea is to detect enter key and than "click" desired button
> 
> first we need JS function:
> 
> function keyUpOnSearchEdit(key, buttonId){
> if ( ! key ){//browser dependend sh!t;)
>          key = event.keyCode;
>      }
> if(key==13){//13 is enter key code
> document.getElementById(buttonId).click();//click on desired button
> 
> return false;//important! to stop event propagation
> }
> }
> 
> 
> than we need input text:
> <h:inputText value="#{offerForm.textToSearch}" id="textToSearch" size="30"
> onkeypress="return /*return in
> important to stop event propagation*/
> keyUpOnSearchEdit(event.which,'f:searchButton')" />
> 
> and finally we need button:
> 
> <x:commandButton value="#{msg.SEARCH_BUTTON}" action="#{offerForm.search}"
> id="searchButton"/>
> 
> 
> cheers
> 
> Slawek
> 
> 
> Hi,
> 
> I have several buttons in my JSF form page. There are also several
> input fields. What I would like is when the user is in one particular
> text field and hits Enter, I want to trigger the button associated
> with it. If I'm in another text field, it should trigger a different
> button.
> 
> Basically I want to change submit button focus with javascript or JSF
> depending on which input field has focus. What is the best way to do
> this?
> 
> -Steve
> 
>

Reply via email to