Jul 16, 2012, 7:39 AM
[CLOSED] TextArea Selection Range
Hi,
I need to know if there is any selection and the range of it in a textarea, in Ext.NET 1.x I do it like this:
NOTE: It has to work on IE and FF
I need to know if there is any selection and the range of it in a textarea, in Ext.NET 1.x I do it like this:
addText: function (text) {
var textArea = txtFormula.el.dom;
if (document.selection) {
textArea.focus();
var sel = document.selection.createRange();
sel.text = text;
}
else if (textArea.selectionStart || textArea.selectionStart == '0') {
var startPos = textArea.selectionStart;
var endPos = textArea.selectionEnd;
textArea.value = textArea.value.substring(0, startPos)
+ text
+ textArea.value.substring(endPos, textArea.value.length);
} else
textArea.value += text;
},
But know anything I'm trying doesn't satisfy my requirements. NOTE: It has to work on IE and FF
Last edited by Daniil; Jul 17, 2012 at 10:48 AM.
Reason: [CLOSED]