471,887 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

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 1255


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
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.