[CLOSED] TextArea Selection Range

  1. #1

    [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:

    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]
  2. #2
    Hi,

    Is there any JavaScript error? For example, here?
    var textArea = txtFormula.el.dom;
    Should not you use
    App.txtFormula
    instead of
    txtFormula
    And, I think, you should use "inputEl" instead of "el".
  3. #3
    No, there isn't any error because I have setted Namespace="" to avoid App namespace.

    And the first case of the if conditional adds text in top of application not inside the textarea.

    But at this moment I only need a form to get start and end index of selected text and I could rewrite the function.
  4. #4
    Quote Originally Posted by Daniil View Post
    And, I think, you should use "inputEl" instead of "el".
    Ok, applying the above causes the function working.


    But at this moment I only need a form to get start and end index of selected text and I could rewrite the function.
    This appears to be working in IE9.
    txtFormula.inputEl.dom.selectionStart
    txtFormula.inputEl.dom.selectionEnd
    Anyways, there is no special things in Ext.NET to deal with the text selection, should deal directly with DOM.
  5. #5
    Yes, it works with inputEl

    Thanks
  6. #6
    So, can we mark the thread as closed?
  7. #7
    Yes you can close it

Similar Threads

  1. [CLOSED] DateField - From To Range
    By thchuong in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 08, 2012, 9:17 AM
  2. [CLOSED] Date range picker...
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 16, 2012, 12:55 PM
  3. [CLOSED] From to date range
    By Raynald_Fontaine in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 30, 2012, 9:52 AM
  4. [CLOSED] From-To Date Range
    By jeremyl in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 30, 2012, 9:52 AM
  5. [CLOSED] [1.2] Date Range Change
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 06, 2011, 4:53 PM

Tags for this Thread

Posting Permissions