Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JavaScript question.

Options
  • 25-01-2002 10:33am
    #1
    Registered Users Posts: 1,783 ✭✭✭


    Quick question:
    Can I get javascript to recognise when a certain key is hit in a text area? I would like to get it to recognise when I hit return, add some text on to the end of the text in the text field/area and still go down to the next line as normal.

    If this is possible is it easy?
    I don't know javascript atm but I might learn it depending on how useful it will be.


Comments

  • Registered Users Posts: 2,781 ✭✭✭amen


    attach to your control
    onKeyPress="KeyPressed(this)"

    function KeyPressed(this)
    {
    //13 is the return key
    if (event.keyCode==13)
    {
    //do what u want here

    }

    }


  • Registered Users Posts: 1,783 ✭✭✭Puck


    Smashin! Thanks a mil!

    I have it done on an Applet already but after working with the Applet for a while I've decided I hate the things. Trying to get an Applet and a Servlet to talk is a real pain in the bum so I figured this would be easier.

    Right so I'm off to pick up some js skills now. Anyone any tips on this? Someone please tell me it's a piece of piss!:)


  • Moderators, Music Moderators Posts: 1,481 Mod ✭✭✭✭satchmo


    Don't worry, it really is a piece of piss. :D
    Webmonkey's always a good place to start.


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    *psssssssssssssssssssssssssh*


    Two hints what that sound is :D


  • Registered Users Posts: 1,783 ✭✭✭Puck


    Grand! I love it when a plan comes together!:D :D


  • Advertisement
  • Registered Users Posts: 1,783 ✭✭✭Puck


    I am able now (thanks to you guys) to append a string to the text in my text area when I hit the return key.
    But is there a way I can add this to somewhere in the middle of the text or anywhere the user selects?

    Not too important I suppose, I mean Boards does the same thing with smileys, i.e. You want to add a smiley to somewhere in the middle of your post but when you click on a smiley it pops up at the end of the text.


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    There's a vBulletin hack for this. Have a look here. If it's not commented, post again and I'll do a diff on it.

    adam


Advertisement