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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.