
January 31st, 2013, 10:04 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 23
Time spent in forums: 2 h 20 m 59 sec
Reputation Power: 0
|
|
|
Adding values to a textarea but seperating them line by line as opposed to one line
Hello,
I need your help,
How can the code be modified below so as to allow the newly added values to appear on separate lines as opposed to just on the same line when the add button is clicked?
Expected Result:
----------------------
Red
Blue
Green
Yellow
Current Result:
----------------------
RedBlueGreenYellow
Code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function add() {
document.getElementById('list').value += document.getElementById('input').value
}
</script>
</head>
<body>
<input type="text" style="width: 154px;" id="input">
<input onclick="add()" type="button" style="width: 20px; height: 22px;" value="+" id="add"><br>
<textarea style="height: 75px;" id="list"></textarea>
</body>
</html>
|