Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Textarea Prob
#1
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.
[Image: Scorpion-Sig3.png]
Reply
#2
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/javascr...ctions.php
Reply
#3
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/archiv...43687.html
Reply
#4
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.
[Image: Scorpion-Sig3.png]
Reply
#5
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)