Link to home
Start Free TrialLog in
Avatar of mostenscer
mostenscer

asked on

How to change/access text in TEXTAREA HTML/Javascript

HOw can I modify text in text Area.  assuming there is already some text in text aria
Avatar of callrs
callrs

<!-- Change text area
      2006-11-01 rs
-->
<form>
<textarea name=text1 style="width: 500px; height: 300px">
</textarea><br>
<input name=in1 value="Some text">
<input type=button value="Click to change text area" onclick="this.form.text1.value=this.form.in1.value"><br>
<input name=in2 value="Add text">
<input type=button value="Click to add to text area" onclick="this.form.text1.value=this.form.text1.value+'\n'+this.form.in2.value">
</form>

Instant Demo: http://www.sendspace.com/file/itvixp changeTextarea.htm
Run this code :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<form ID="Form1">
<textarea style="width: 500px; height: 300px" ID="Textarea1">
Hello
</textarea><br>

<input value="Some text" ID="Text1">
<input type=button value="Click to change text area" onclick='document.getElementById("Textarea1").value = document.getElementById("Text1").value' ID="Button1" NAME="Button1"><br>
<input value="Add text" ID="Text2">
<input type=button value="Click to add to text area" onclick='document.getElementById("Textarea1").value =document.getElementById("Textarea1").value +"\n"+ document.getElementById("Text2").value' ID="Button2" NAME="Button2">
</form>

</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of callrs
callrs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial