Jump to content

Add a new value to the current value of a textbox


son.of.the.morning

Recommended Posts

I have button that inserts test into a textbox in addition to it's current value. Current it's placing the new value to the end of the current value. What i need is for it to insert this additional string to the current place of the cursor.

Does anyone know a solution for this problem.

<script type="text/javascript">
function addquote() {
	quote = "[quote][/quote]";
	document.ArticleForm.ArticleBody.value = document.ArticleForm.ArticleBody.value+= quote;
}
</script>

Did you google for this answer? There are many threads around the internet regarding this subject and are not hard to find.

 

Yes you can. The IE route is different to the other's (as usual), requiring the creation and manipulation of ranges.

 

All the other browsers use just selectionStart and selectionEnd along with setSelectionRange.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.