Click to See Complete Forum and Search --> : textarea question


gordan
09-01-2003, 12:45 PM
Hi.

I have a text area and would like to add some text to it when I click a button so I put this code:
var txtarea = document.form.text;
txtarea.focus();
txtarea.value+="some text";

the problem is that this adds "some text" on the end of the text in my textarea
I want the "some text" after my current cursor position

could you help me do that :-)

thanks, Gordan

Jupac
09-01-2003, 02:06 PM
use
var text="your test here";
document.formnamehere.textareanamehere.value=text;

gordan
09-01-2003, 02:12 PM
i would like to insert! "some text" on my cursor position
the text before and after cursor stays unchanged :)

Jupac
09-01-2003, 02:25 PM
here
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled</title>
<script type="text/javascript">
<!--
function change(){
var text="yourtexthere";

document.form1.box1.value=text;
}
// -->
</script>
</head>
<body>
<form name="form1">
<textarea name="box1">text</textarea>
<input type="button" value="change" onclick="change();">
</form>

</body>
</html>

gordan
09-01-2003, 04:00 PM
here's what i want :D
users enters "1234567" in the textarea. then clicks between 4 and 5 and hits "the button". now the textarea has the value "1234sometext567"

thanks, Gordan