Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Form Submission issue

    Hi
    I have a scenario like having two textbox A & B in a form

    From "A" textbox if i press "Enter" key it should submit the form
    Form "B" textbox if i press "Enter" key it should call another javascript method which willwill be calling a <href> url.

    Issue : for my for two text box if i press "Enter" key it is submitting a form.

    Please any one give me the solution .it will be great .........

    Thanks,
    Rajesh

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,244
    Thanks
    203
    Thanked 2,555 Times in 2,533 Posts
    Here you are:-


    Code:
    A <input type = "text" id = "boxA" onkeydown ="if (event.keyCode == 13) {checkit(this)} ">
    <br>
    B <input type = "text" id = "boxB" onkeydown ="if (event.keyCode == 13)  {checkit(this)} ">
    
    <script type = "text/javascript">
    
    function checkit(which) {
    var boxid = which.id;
    if (boxid == "boxA") {
    // do this
    }
    if (boxid == "boxB") {
    // do that
    }
    }
    
    </script>

    "The only thing to do with good advice is pass it on. It is never any use to oneself."- Oscar Wilde (Irish Poet, Novelist, Dramatist and Critic, 1854-1900)

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for our reply

    if i have "Submit Button" or <input type="image"/>inside the form it is not working.

    Instead i have a <a > tag its working.

    if u have solution for the above case ,please share it.

    Regards,
    Rajesh.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,244
    Thanks
    203
    Thanked 2,555 Times in 2,533 Posts
    Quote Originally Posted by rathe_8387 View Post
    Thanks for our reply

    if i have "Submit Button" or <input type="image"/>inside the form it is not working.

    Instead i have a <a > tag its working.

    if u have solution for the above case ,please share it.

    Regards,
    Rajesh.
    Sorry, I don't understand you. You said you had two textboxes. You did not mention a submit button, which will of course submit the form regardless.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •