Hi
I m finding for a solution. But this is very critical I think. Though its very critical, I hope you will solve this. problem is as below

I have 5 divs with no ID. say as

<div>The quick brown fox jumps over the lazy dog<input name="" type="button" /></div>
<div>this is another dive for copy<input name="" type="button" /></div>
<textarea name="" cols="" rows="" style="width:100%">This the text wher I want to add my text</textarea>

Now I want that from 1st div I will select some words as below (in red color)

<div>The quick brown [B]fox jumps over[/B] the lazy dog<input name="" type="button" /></div>

and after clicking on the button it will add last of textarea content. How can I do that.
Remember also I m using tinymce. so how it will add in text area editor. Please help me it it is possible

Here is the complete code, but you can modify according to your requirements

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">

function addText()
{
	var txt = '';
	if (window.getSelection)
	{
		txt = window.getSelection();
	}
	else if (document.getSelection) // FireFox
	{
		txt = document.getSelection();
	}
	else if (document.selection)  // IE 6/7
	{
		txt = document.selection.createRange().text;
	}	
	document.getElementById('ta1').value=txt;
}
</script>
</head>

<body>
<div id="div1" style="float:left">The quick brown fox jumps over the lazy dog
<input name="" type="button" value=">>" onclick="addText()" /></div>

<!--<div>this is another dive for copy<input name="" type="button" /></div>-->

<textarea name="ta1" id="ta1" cols="25" rows="10">This the text where I want to add my text</textarea>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.