problem with keyup event in mozilla

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsuns82
    New Member
    • Mar 2007
    • 58

    problem with keyup event in mozilla

    Code:
    <script>
    function TrapEvent(event)
    {
    if (event.keyCode == 13) {
    document.getElementById("form2:go2").click();
    return false;
    }
    else
    return true;
    }
    </script>
    <body>
    <h:form id="form">
    <h:commandButton id="go1" >
    
    <h:inputText onkeyup="TrapEvent(event)">
    
    <h:commandButton id="go2" >
    
    </h:form>
    </body>
    when the user hits enter key,first button will always be submitted by default,I have to click the second command button from text field using javascript,i done it using onkeyup,but its not working in mozilla,any idea???

    --------------------------------------------------------------------------------

    regards,
    sundar
    Last edited by gits; Aug 30 '07, 09:03 AM. Reason: added CODE tags
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by gsuns82
    <script>
    function TrapEvent(event )
    {
    if (event.keyCode == 13) {
    document.getEle mentById("form2 :go2").click();
    return false;
    }
    else
    return true;
    }
    </script>
    <body>
    <h:form id="form">
    <h:commandButto n id="go1" >

    <h:inputText onkeyup="TrapEv ent(event)">

    <h:commandButto n id="go2" >

    </h:form>
    </body>

    when the user hits enter key,first button will always be submitted by default,I have to click the second command button from text field using javascript,i done it using onkeyup,but its not working in mozilla,any idea???

    --------------------------------------------------------------------------------

    regards,
    sundar

    Follow Post Guidelines.
    I mean use Code Tags.
    Do one thing just write....go2 instead of form2.go2.
    Then see what happens

    Kind regards,
    Dmjpro.

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #3
      splitted threads since that is a new question and you shouldn't do that in a thread that concerns simply an other problem!

      MOD

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by gsuns82
        Code:
        <script>
        function TrapEvent(event)
        {
        if (event.keyCode == 13) {
        document.getElementById("form2:go2").click();
        return false;
        }
        else
        return true;
        }
        </script>
        <body>
        <h:form id="form">
        <h:commandButton id="go1" >
        
        <h:inputText onkeyup="TrapEvent(event)">
        
        <h:commandButton id="go2" >
        
        </h:form>
        </body>
        when the user hits enter key,first button will always be submitted by default,I have to click the second command button from text field using javascript,i done it using onkeyup,but its not working in mozilla,any idea???

        --------------------------------------------------------------------------------

        regards,
        sundar
        Oh ****!
        What a mistake I did.
        Now I got what is wrong with your code.
        In Mozilla event.keyCode never works.
        It will be event.which.

        Anyway Best of Luck with your Code.

        Kind regards,
        Dmjpro.

        Comment

        Working...