Hello,
I have a page with a text area and an image with the copy sign on it. When the copy sign image is pressed the copy sign will appear in the text box with the cursor right behind it.
I have a couple of problems.
1.
I would like to go back with the cursor in the text that is written and then enter a new copy sign if I want to at that specific location with the cursor right behind it. If I move the cursor back anywhere in the text and then press the copy button the sign now appears at the last position in the string.
When the copy sign is pressed in the very beginning, I would like the text that is already entered in the text box initially (-Click here to enter text) to disappear and the copy sign to be the first sign to appear without having to start clicking in the text area. This is by far not as important as the problem mentioned in 1. However it would be nice to solve it as well.
You can see the page here:
[url]http://www.trhtk.no/Lenker/vti_ex/tb/textbox.html
It is also interesting why the text area moves up in IE when the copy sign is pressed so that the whole box is visible in the window in lower resolutions. Would be nice to know why that happens and how it can be controlled even though it is not so much of a problem.
I hope someone can help me with this. I appreciate all the help I can get ?
Here is the relevant code:
<script language=”javascript” type=”text/javascript”>
function get_focus() {
document.getElementById(“inputtext”).focus();
}
function clearText(field) {
if (field.defaultValue == field.value) field.value = ”;
else if (field.value == ”) field.value = field.defaultValue;
}
if (document.images) {
img_on =new Image(); img_on.src =”images/copy_down.gif”;
img_off=new Image(); img_off.src=”images/copy_up.gif”;
}
function handlePress() {
if (document.images) document.imgName.src=img_on.src;
}
function handleRelease() {
if (document.images) document.imgName.src=img_off.src;
}
</script>
<table width=960 bgcolor=”#f1ebc7″ border=”0″ cellspacing=”0″ cellpadding=”0″ class=brown>
<tr>
<td colspan=2 height=10></td>
</tr>
<tr>
<form name=”myform”>
<td width=19></td>
<td><img name=imgName src=”images/copy_up.gif” OnMouseDown=”myform.inputtext.value=myform.inputtext.value + ‘©’, handlePress();return true;” OnMouseUp=”document.myform.inputtext.focus(), handleRelease();return true;” onMouseOut=”handleRelease();return true;”></td>
<td width=104></td>
<td valign=middle>
<input style=”width:100px;height:30px;font-size:11px;” type=”reset” value=”START AGAIN” id=reset1 name=reset1>
</td>
<td width=404></td>
</tr>
<tr>
<td height=5 colspan=28></td>
</tr>
</table>
<table width=960 bgcolor=”#f1ebc7″ border=”0″ cellspacing=”0″ class=brown>
<tr>
<td width=16></td>
<td><textarea id=dummy name=”inputtext” value=”” onFocus=”clearText(this)” onBlur=”clearText(this)”>- Click here to enter your text
</textarea>
</td>
<td width=14></td>
</form>
</tr>
<tr>
<td colspan=3 height=15></td>
</tr>
</table>