473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Return selected text in textarea/text box

Hi,

I was just wondering if there is a way to return the highlighted text in a text box or a text area.

For instance:
<textarea id="foo"> The quick brown fox jumped ... </textarea>
<input type=text id="foo" value="The quick brown fox jumped ... ">

Lets say I highlight the text 'brown fox' in one of those fields, is there a way for me to get that text and say, for instance, copy to clipboard without using the mouse menu etc..

I get the copy to the clipboard part and tried document.getSelection() in mozilla
doesnt, and it doesnt seem to work for form fields. I'd be very thankful to anyone who has a solution to this.

Thanks in advance.
Jun 22 '08 #1
3 1500
acoder
16,027 Expert Mod 8TB
See this link for starters. Oh, and you can't have two elements with the same ID.
Jun 22 '08 #2
Great that is just what I needed! :)

Oh, and you can't have two elements with the same ID.
Right, it was more like textarea or text box, anyway thanks for pointing it out.
Jun 22 '08 #3
acoder
16,027 Expert Mod 8TB
Oh, I see, nvm.

Anyway, glad to see the link helped. If you have more questions, post again.

PS. I noticed that you've just joined, so here's a "welcome to Bytes!" Hope you enjoy your stay ;)
Jun 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Shaiboy_UK | last post by:
Hi All, Hope someone can help here!! I'm putting a standard mail page together, that will allow my users to sent templete emails out to people. The files are stored in text files. I have...
4
by: Dru | last post by:
Hi, I am making a textarea for people to add/modify their text for descriptions products. I want to have buttons (or just text links) with functions that will allow them to bold, italicize, sup,...
7
by: Razzbar | last post by:
I have a textarea and some buttons. The buttons apply functions to the text the user selects, i.e. the good old "wrap with a tag" thing we all have seen in 100 different editors. Trouble is,...
8
by: McKirahan | last post by:
Firefox does not reflect selected option via innerHTML How do I get Firefox to reflect selected option values? <html> <head> <title>FFinner.htm</title> <script type="text/javascript">...
3
by: gooderthanyou | last post by:
I have a textfield and you of course you can select text... When they hit the bold button I want it to obtain the selected text and bold it, the hard part is trying to figure out if javascript...
3
by: brisco5 | last post by:
I have a TEXTAREA element. A user right clicks within in to get the context menu and they select "paste". I want my javascript code to know that they selected "paste". I know you can capture the...
4
by: Adnan Siddiqi | last post by:
Hi Pardon me if I am not making any sense.What I want to know the cordinates of selected text by user so that i can save/retrieve them later.is It possible.I am lookig for both IE and Firefox...
2
by: thuythu | last post by:
Please help me.... I used and Javascript to view the data. But when i click button open a popup windows, then select data and click save button. The popup close and return the main page, but the...
2
by: King of the R.O.U.S.'s | last post by:
Hi All How do I replace selected text in a textarea with JavaScript? I have a text area that the user can select what they want then press a button that will pick up the selected text, make...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.