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 3 of 3
  1. #1
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts

    Insert text in textarea at position of cursor

    I'm clueless on how to do this, as my js knowledge is very limited. I have option/select menus, which trigger off js prompts to ask for text. Once the text is entrered, it goes into a textarea. Now I don't always want the text to go at the start or end of the textarea, but where the cursor is. I currenty have
    Code:
    function headers(type){
    		var newheader = prompt('Insert '+type,'');
    		document.form1.content.value += '['+type+']'+newheader+'[/'+type+'] \n';
    	}
    How can I modify it to insert text where the cursor is? Ta
    Last edited by Nightfire; 01-20-2005 at 03:04 AM.

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    For what it's worth there is an IE version I once found before for someone on this forum. Insert data where the cursor is in a textbox
    Last edited by Brandoe85; 01-20-2005 at 04:47 AM.

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Ta, will have a play around with it


  •  

    Posting Permissions

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