vbkris
Allot of progress has been made (90% complete) since my last post, the following is cut n paste code and has notes intended to be read once the page has been run. It contains some .asp code (only used for formatting within the textareas. Formatting will be lost but it will run and work as a .html page)
I am a bit stuck getting the remaining functionality to work (not to techo with js), createRange - yes this was the function I needed. It works well
Would appreciate any input
-----------------------------------start--------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var copyStr;
var foc=0;
var foc2=0;
var lbr;
function moveSelection(where,btn,whofoc)
{
if(whofoc==0)
{
alert('The source textarea does not have focus and thus, no selection!');
return false;
}
lbr='';
if (document.selection)
{
tmp=where.value;
sel = document.selection.createRange();
copyStr=sel.text;
document.selection.clear();
tmpx=where.value.replace(/\r\n/g,' ');
tmpy=tmp.replace(/\r\n/g,' ');
tmpz=tmpy.length-tmpx.length-copyStr.length;
for (var i=0;i<tmpz;i++)
{
lbr+='\r\n';
}
}
else if (where.selectionStart || where.selectionStart == '0')
{
var begin = where.selectionStart;
var end = where.selectionEnd;
copyStr=where.value.substring(begin,end);
where.value=where.value.substring(0,begin)+where.value.substring(end,where.value.length)
}
if(copyStr=="")
{
alert('No text selected to be moved!')
}
else
{
document.forms[0].briefString.value+=copyStr+lbr;
}
}
//-->
</script>
</head>
<body>
<!--the following notes are intended to be read once the page has been run in the browser -->
This pages objective is 90% finished. There are categories in each of
the four text areas, Eg EVENTS:etc... The bottom three areas will
contain text against each section. At this point and time, if you
select text form one of the bottom three areas and click 'move selected'
the text is moved to the top textArea(appended to the bottom) - nice! I am trying to:<br>
a..detect which section the selected text came from<br>
b..move this text in to this category in the top textArea<br>
Am I dreaming?<bR>
(BTW: if you have copied this page as a .html ext you will not see the correct 'textArea content' formatting - however it will still work)
<form>
<textarea name="briefString" rows="13" cols="60">
EVENTS:<%= vbcrlf & vbcrlf %>ISSUES:<%= vbcrlf & vbcrlf %>VISITS:<%= vbcrlf & vbcrlf %>REPUTATION:<%= vbcrlf & vbcrlf %>MINISTERIALS:<%= vbcrlf & vbcrlf %>PERSONNAL:<%= vbcrlf & vbcrlf %>ACHIEVEMENTS:</textarea>
<br><br>
<textarea name="ta1" rows="5" cols="60" onfocus="foc=1" onblur="foc=0">
EVENTS:<%= vbcrlf %>aaaaaaaa aaaaaaaaa aaaaaaaa aaaaaaa<%= vbcrlf %>
ISSUES:<%= vbcrlf %>aaaaaaaa aaaaaaaaa aaaaaaaa aaaaaaa<%= vbcrlf %>
VISITS:<%= vbcrlf %>aaaaaaaa aaaaaaaaa aaaaaaaa aaaaaaa<%= vbcrlf %>
REPUTATION:<%= vbcrlf %>aaaaaaaa aaaaaaaaa aaaaaaaa aaaaaaa<%= vbcrlf %>
MINISTERIALS:<%= vbcrlf %>aaaaaaaa aaaaaaaaa aaaaaaaa aaaaaaa<%= vbcrlf %>
PERSONNAL:<%= vbcrlf %>aaaaaaaa aaaaaaaaa aaaaaaaa aaaaaaa<%= vbcrlf %>
ACHIEVEMENTS:<%= vbcrlf %>aaaaaaaa aaaaaaaaa aaaaaaaa aaaaaaa
</textarea><br>
<input name="btn" type="button" onmousedown="foc2=foc;" onmouseup="moveSelection(this.form.ta1,this,foc2)" value="move selected">
<br><br>
<textarea name="ta2" rows="5" cols="60" onfocus="foc=1" onblur="foc=0">
EVENTS:<%= vbcrlf %>bbbbbbbbb bbbbbbbbbb bbbbbbbbbb bbbb<%= vbcrlf %>
ISSUES:<%= vbcrlf %>bbbbbbbb b bbbbbbbb bbbbbbbb bbbbbb<%= vbcrlf %>
VISITS:<%= vbcrlf %>bbbbbbbb b bbbbbbbb bbbbbbbb bbbbbb<%= vbcrlf %>
REPUTATION:<%= vbcrlf %>bbbbbbbb b bbbbbbbb bbbbbbbb bbbbbb<%= vbcrlf %>
MINISTERIALS:<%= vbcrlf %>bbbbbbbb b bbbbbbbb bbbbbbbb bbbbbb<%= vbcrlf %>
PERSONNAL:<%= vbcrlf %>bbbbbbbb b bbbbbbbb bbbbbbbb bbbbbb<%= vbcrlf %>
ACHIEVEMENTS:<%= vbcrlf %>bbbbbbbb b bbbbbbbb bbbbbbbb bbbbbb
</textarea><br>
<input name="btn" type="button" onmousedown="foc2=foc;" onmouseup="moveSelection(this.form.ta2,this,foc2)" value="move selected">
<br><br>
<textarea name="ta3" rows="5" cols="60" onfocus="foc=1" onblur="foc=0">
EVENTS:<%= vbcrlf %>ccccc ccccccccc cccccccc ccccccc ccc<%= vbcrlf %>
ISSUES:<%= vbcrlf %>ccccc ccccccccc cccccccc ccccccc ccc<%= vbcrlf %>
VISITS:<%= vbcrlf %>ccccc ccccccccc cccccccc ccccccc ccc<%= vbcrlf %>
REPUTATION:<%= vbcrlf %>ccccc ccccccccc cccccccc ccccccc ccc<%= vbcrlf %>
MINISTERIALS:<%= vbcrlf %>ccccc ccccccccc cccccccc ccccccc ccc<%= vbcrlf %>
PERSONNAL:<%= vbcrlf %>ccccc ccccccccc cccccccc ccccccc ccc<%= vbcrlf %>
ACHIEVEMENTS:<%= vbcrlf %>ccccc ccccccccc cccccccc ccccccc ccc
</textarea><br>
<input name="btn" type="button" onmousedown="foc2=foc;" onmouseup="moveSelection(this.form.ta3,this,foc2)" value="move selected">
<br><br>
</form>
</body>
</html>
-----------------------------------finish--------------------------------