Support Forums
Textarea Prob - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Webmaster Support (https://www.supportforums.net/forumdisplay.php?fid=36)
+---- Forum: Website Development (https://www.supportforums.net/forumdisplay.php?fid=43)
+---- Thread: Textarea Prob (/showthread.php?tid=2617)



Textarea Prob - Scorpion - 11-06-2009

What's Up?

OK, So with my latest addition to my project, I need to be able to change the text of a textarea using JavaScript. I goggled around for ages but all the scripts I found didn't work.

Anyone Know?

Thanks Bye.


RE: Textarea Prob - Gaijin - 11-06-2009

Ok as much as I could understand your need, you want to replace parts of the text inside the textarea.
Here is a script that changes SF/Sf/sF/sf to SupportForums.net everytime a key is up.

Code:
<html>
<head>
<script language="javascript" type="text/javascript">
function editText(textbox) {
    var text = "SupportForums.net"
    var newText = textbox.value.replace(/SF/i, text);
    textbox.value = newText;
}
</script>
</head>
<body>
<form name="myForm" action="" method="post">
<textarea onkeyup="editText(this);"></textarea>
</form>
</body>
</html>

Read this here, http://www.tizag.com/javascriptT/javascript-string-functions.php


RE: Textarea Prob - zone - 11-06-2009

You can also take a look at this :
Code:
onmouseover="functionToExecute('<some argument here for text area's text>')". a simple demo:

<html>
<head>
<title>Example</title>
<script type="text/javascript">
function changeText(val){
var txtArea = document.getElementById('imgdesc');
txtArea.value = val;
}
</script>
</head>
<body>
<textArea id="imgdesc"></textArea>
<img src="img1.gif" alt="Image 1" onmouseover="changeText(this.alt)">
<img src="img2.gif" alt="Image 2" onmouseover="changeText(this.alt)">
<img src="img3.gif" alt="Image 3" onmouseover="changeText(this.alt)">
<img src="img4.gif" alt="Image 4" onmouseover="changeText(this.alt)">
<img src="img5.gif" alt="Image 5" onmouseover="changeText(this.alt)">
<img src="img6.gif" alt="Image 6" onmouseover="changeText(this.alt)">
</body>
</html>
Source from:
http://www.webdeveloper.com/forum/archive/index.php/t-43687.html


RE: Textarea Prob - Scorpion - 11-07-2009

Is it possible to change
Code:
<textarea tabindex="1" autocomplete="off" accesskey="u" name="status" id="status" rows="2" cols="40"/>

To

Code:
<textarea tabindex="1" autocomplete="off" accesskey="u" name="status" id="status" rows="2" cols="40"/>What i want to say</textarea>

Via javascript? If i got the working java script, I was hoping to put it into a firefox addon.


RE: Textarea Prob - Gaijin - 11-07-2009

Yes it's possible, to acces the HTML form with JavaScript the form needs a name first.

Code:
<form name="someForm".....

Then you can create your text area and give it also a name,
Code:
<textarea name="someText"......

To control this form, all you need to do is call it by the name.

Code:
document.someForm.someText.value = "Textarea is controled by Aliens";

"value" is what you need.