Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Placing character in Textarea


Message #1 by "Ken Schlender" <schlenderk@e...> on Fri, 9 Nov 2001 11:39:32 -0700
This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C16B4F.B52B8080
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

MessageIt is wonderful.  Thankyou very much.  I will give you and the 
group credit in the script.

Ken Schlender
  ----- Original Message -----
  From: Nyman, Robert
  To: schlenderk@e...
  Sent: Monday, November 12, 2001 2:42 AM
  Subject: [javascript] Re: Placing character in Textarea


  Ken, this will do the trick for you (IE only, though):


  <html>
  <head>
   <title>Cursor on textarea</title>
  
   <script language=3D"JavaScript" type=3D"text/javascript">
      <!--
    var oRng =3D null;
       function checkCursor(){
           oRng =3D document.selection.createRange();  
          }
    function insertText(){
           if(oRng){
      oRng.text =3D "HELLO";
     }
          }
      //-->
      </script>
  </head>

  <body>

  <textarea id=3D"inputTextarea" onClick=3D"checkCursor()" 
onKeyUp=3D"checkCursor()">This is the text...</textarea>
  <input type=3D"button" value=3D"Check cursor" onClick=3D"insertText()"

  </body>
  </html>


  /Robert


    -----Original Message-----
    From: Gerhard Wentink [mailto:data@w...]
    Sent: den 10 november 2001 17:27
    To: javascript
    Subject: [javascript] Re: Placing character in Textarea


    AFAIK you can't

    Gerhard Wentink
      ----- Original Message -----
      From: Ken Schlender
      To: javascript
      Sent: Friday, November 09, 2001 7:39 PM
      Subject: [javascript] Placing character in Textarea


      I would like to place a unicode character into a location in a 
text area.  I know how to add it after the last character but not in the 
middle of the text.

      I am writing a utilty that would allow users to enter mathematical 
symbols into a text area and then copy it to a word document.

      How do I find out where the cursor is in a textarea?

      Thanks,
      Ken Schlender
$subst('Email.Unsub')

robert.nyman@i...
$subst('Email.Unsub')

$subst('Email.Unsub')




  Return to Index