prajan
prajan

Reputation: 189

Append text into TextArea

I want to append text inside Textarea. The text should be appended immediate after the cursor position and not at the end.

Here is my code:

The HTML:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<textarea id="textarea1"></textarea>
<br><input type="button" value="Write blah blah" onclick="addtxt('textarea1')">
</body>
</html>

The Script:

<script>
function addtxt(input) {
var obj=document.getElementById(input);
obj.value+="blah test 123"
}
</script>

The above code is live at: http://jsfiddle.net/zGrkF/

Thanks in advance..

Upvotes: 4

Views: 2114

Answers (2)

Kicsi Mano
Kicsi Mano

Reputation: 3761

Try jQuery.

With that the code is the following:

$("#textarea1").hover(
    function()
    {
        $(this).value('IN');
    },
    function()
    {
        $(this).value('OUT');
    });

OR

$("#textarea1").mouseover(
    function()
    {
        $(this).value('IN');
    });

UPDATED:

Try this link

Upvotes: 1

Town
Town

Reputation: 14906

The jQuery Field Selection plugin is quite old but should enable you to do everything you want and more.

Upvotes: 0

Related Questions