Tutorials
Resources
Forum
Interview
Jobs
Projects
Offshore Development
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Talk to Us
|
My Profile
Sign In
Register
AdSense Revenue
Gifts
Active Members
Today
krishnasamy
(83)
Karthikeyan S
(80)
Rajesh(March-20...
(68)
Last 7 Days
D.Jeya kumar(J...
(1198)
Athira Appukut...
(1137)
UltimateRengan
(1134)
more...
How to retrieve selected text from a textbox or textarea
Posted Date: 01 May 2008 Resource Type:
Code Snippets
Category:
Javascript
Posted By:
Asha Mathews
Member Level:
Gold
Rating:
Points
: 20
the text highlighted is saved and shown in a popup in this example, but we can use it in any applications. (this is similar to T-SQL query execution process, in which we can execute only the highlighted portion).
<script language=javascript>
function getSelText()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
//var mytxt = txt;
//document.getElementById("selectedtext").value = txt;
alert(txt);
alert(document.getElementById("selectedtext").value);
}
</script>
<html>
<form name=aform action="" >
<textarea name="selectedtext" rows="5" cols="20" ></textarea><br />
<input type="button" value="Get selection" onClick="getSelText()">
</form>
</html>
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
How to create Namespace in Javascript
Previous Resource:
Generate Dynamic textbox in client using JAVASCRIPT
Return to Discussion Resource Index
Post New Resource
Category:
Javascript
Post resources and
earn money
!
Related Resources
Declaring Variables in JavaScript
Open File using its Name
Get Browser Language using JavaScript
Run exe file using Java Script
Scrolling Date in the Status Bar using Javascript
dotNet Slackers
BizTalk Adaptors
Web Design
web conferencing
Contact Us
Privacy Policy
Terms Of Use