question relating to document.selection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • c.anandkumar@gmail.com

    #1

    question relating to document.selection

    Hi
    How do I figure out if a selection in a document is in a particular
    control?
    I have a TEXTAREA in which a user can type in some text, select some
    text and 'apply' tags around it clicking a button. I am using
    document.select ion.createRange () to create a textRange object and then
    modify its text property to suit the action. But the problem is I want
    to limit this action to a few "INPUT type=text" and TEXTAREA controls.

    How do I check if the selection is made in one of a set of controls?
    Thanks for your help
    Anand

  • Martin Honnen

    #2
    Re: question relating to document.select ion



    c.anandkumar@gm ail.com wrote:

    [color=blue]
    > How do I figure out if a selection in a document is in a particular
    > control?
    > I have a TEXTAREA in which a user can type in some text, select some
    > text and 'apply' tags around it clicking a button. I am using
    > document.select ion.createRange () to create a textRange object and then
    > modify its text property to suit the action. But the problem is I want
    > to limit this action to a few "INPUT type=text" and TEXTAREA controls.
    >
    > How do I check if the selection is made in one of a set of controls?[/color]

    var range = document.select ion.createRange ();
    var textarea = document.forms. formName.elemen ts.textareaName ;
    if (range.parentEl ement() = textarea) {
    ...
    }
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    Working...