Reputation: 13
I have been looking for this script everywhere however i was unable to find it. I am trying to create a simple donation count. When a value is added inside a textbox I want it to be permanently fixed into second textbox after button submission. Thanks in advance for all your help.
Upvotes: 1
Views: 88
Reputation: 28837
Try this:
<script>
window.onload = function () {
var textfield6 = document.getElementById('textfield6');
textfield6.value = 0;
document.querySelector('input[type=button]').onclick = function () {
textfield6.value = parseInt(textfield6.value) + parseInt(document.getElementById('textfield5').value);
}
}
</script>
Demo here
Upvotes: 0
Reputation: 56501
1) First get the value from textBox1 (assuming id=textbox1
)
2) Assign the value to second textbox (assuming id=textbox2
)
3) Add the below code in form submission or button click.
document.getElementById('textbox2').value =
document.getElementById('textbox1').value
Upvotes: 1