Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert value into TEXTAREA where cursor was

tironeSep 6 2013 — edited Sep 7 2013

Hi all,

I would like to insert into a text area. at the cursor position (or replace selected text), a text .

I'm trying to use the following script, but I can not make it work.

(see  .. http://stackoverflow.com/questions/5889127/insert-value-into-textarea-where-cursor-was)

     

thanks in advance


Regards

saverio

=======================================

My texarea item is P200_AFORMULA

========================================

function insertAt (myField, myValue, startSel, endSel) {

    if (startSel || startSel == '0') {

        var startPos = startSel;

        var endPos = endSel;

        myField.val(myField.val().substring(0, startPos)+ myValue+ myField.val().substring(endPos, myField.val().length));

  }

  else {

      myField.val() += myValue;

  }

}

// calling the function

var targetBox = $("textarea#P200_AFORMULA"),startSel,endSel;

targetBox.bind('focusout', function() {

    //insertAtCursor(this, 'how do you do');

    startSel = this.selectionStart;

    endSel = this.selectionEnd;

});

var mytext = 'INSETED TEXT';

insertAt(targetBox, mytext , startSel, endSel);

}

This post has been answered by tirone on Sep 7 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2013
Added on Sep 6 2013
2 comments
445 views