469,328 Members | 1,327 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

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.selection.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

Jul 23 '05 #1
1 1207


c.**********@gmail.com wrote:

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.selection.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?


var range = document.selection.createRange();
var textarea = document.forms.formName.elements.textareaName;
if (range.parentElement() = textarea) {
...
}
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by volume | last post: by
3 posts views Thread by Adam Faulkner via DotNetMonster.com | last post: by
2 posts views Thread by Newbie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.