insert an element at a particular position in text area

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

insert an element at a particular position in text area

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

read the second link.
Post Reply