I have the following code :
JavaScript
x
5
1
i = 0;
2
function add_task(){
3
return document.getElementById("tasklist").value += (document.getElementById("addtask").value+"n");
4
}
5
JavaScript
1
12
12
1
#pos{
2
position: absolute;
3
bottom: 25px;
4
text-align:center;
5
}
6
7
form{
8
padding-left:70px;}
9
10
h1{padding:50px; color:blue}
11
12
#body {border:5px solid black;}
JavaScript
1
14
14
1
<form name="form1">
2
<label for="addtask">Add task : </label>
3
<input type="text" id="addtask"/>
4
<button id="ad" onclick="add_task()">Add task</button><br><br>
5
<label style="vertical-align:top;">Task list :</label>
6
<textarea id="tasklist" rows=10>
7
</textarea>
8
<div id="pos">
9
<label for="nexttask">Next task : </label>
10
<input type="text" id="nexttask"/>
11
<button id="nt" onclick="next_task">Show Next task</button><br>
12
13
</div>
14
</form>
I need to copy the text entered in textbox and paste in the textarea. But the text is displayed and erased immediately like blinking. I want that to be displayed permanently.
Please guide me!
Advertisement
Answer
<button>
s, by default are type="submit"
, so clicking is submitting your form. Add type="button"
to your button.