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
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.getEleme ntById("Te xtarea1"). value = document.getElementById("T ext1").val ue' ID="Button1" NAME="Button1"><br>
<input value="Add text" ID="Text2">
<input type=button value="Click to add to text area" onclick='document.getEleme ntById("Te xtarea1"). value =document.getElementById(" Textarea1" ).value +"\n"+ document.getElementById("T ext2").val ue' ID="Button2" NAME="Button2">
</form>
</body>
</html>
<!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.getEleme
<input value="Add text" ID="Text2">
<input type=button value="Click to add to text area" onclick='document.getEleme
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.v
<input name=in2 value="Add text">
<input type=button value="Click to add to text area" onclick="this.form.text1.v
</form>
Instant Demo: http://www.sendspace.com/file/itvixp changeTextarea.htm