Click to See Complete Forum and Search --> : to add the values to text area which are formatted


sachin
03-11-2003, 11:57 AM
Hi,

I am adding the values typed in text box toa text area on click of a button.The text area shows values 2 nd value added
next to the first value.I wanted the 2nd value to appear in the next line.

here is the sample code.


<html>
<head>
<script>
function test()
{

document.frmupper.Textarea1.value=document.frmupper.Textarea1.value + document.frmupper.txtupper.value;

}

</script>

</head>
<form name="frmupper">
Upper Form
<input type="hidden" name="h1" value="inital">
<input type="text" name="txtupper" value="txtupper">
<input type="button" name="add" value="add" onclick="test();">
<br />
<textarea name="Textarea1" rows="5" readOnly cols="65" ID="Textarea1"></textarea></td>
</form>
</html>

pyro
03-11-2003, 12:03 PM
Try this...

function test()
{
if (document.frmupper.Textarea1.value == "")
{
document.frmupper.Textarea1.value = document.frmupper.txtupper.value;
}
else
{
document.frmupper.Textarea1.value += "\n"+document.frmupper.txtupper.value;
}
}

sachin
03-11-2003, 12:50 PM
Thanks a lot.
it is working.