hi

here is the situation...

page contains:
-input text for typing search string
-command button with action that search typed text
-lots of other command buttons

current scenario:
-user type somme text to inputText
-user takes mouse to hand, click search button, waits, ses result, be happy;)
-that works grat;)


situation demanded by boss:
-user type somme text to inputText
-user press ENTER key, waits, see result, bee happy
-should work, but doesnt:/

problem:
if there would be only ONE comand button, than after press eneter key it would be default "clicked" (as in html specyfiacation according do submit buttons)


but as i have many commandbuttons (html submit inputs), than depends on browser ,somme on them is default clicked when presing enter



i tried to do this:

function keyUpOnMyText(key){
        //if key is ENTER (detecting enter works fine) then:
        document.getElementById('formId:searchButton').click();
}

<h:inputText value=blah onkeyup="keyUpOnMyText(event.which)"/>
<h:commandButton value=blah action=blah id="searchButton"/>
<%/*****  many other buttons *****/%>



but it doesn work as i expected:/
when i press ener then browser propagates default submit action of the form (one of other buttons) before my JS function can "click" the search button:/


question: how to stop browser from calling submit button when user press enter??

slawek

Reply via email to