Page 1 of 1

insert an element at a particular position in text area

Posted: Fri Sep 09, 2005 5:43 pm
by raghavan20
Hi guys,

I have a textarea and I want to get the position of the cursor in the text area and want to insert some custom tags there.

I dont see caretPos working.

any help deeply appreciated.

Posted: Fri Sep 09, 2005 5:48 pm
by feyd

Posted: Fri Sep 09, 2005 8:10 pm
by raghavan20
I am trying to select a textarea and get its contents which does not happen...why

Code: Select all

<script>
	var range = document.frmMessage.taMessage.createTextRange();
	alert(range);
	alert ("range text:" + range.text);
</script>

<form method="post" action="" name="frmMessage">
<textarea cols="50" rows="5" name="taMessage"></textarea>
</form>
I have seen in the examples how to move to a location; but how do i get the current position?

Posted: Fri Sep 09, 2005 8:42 pm
by feyd
read the second link.