Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
18
rated 0 times [  22] [ 4]  / answers: 1 / hits: 25134  / 14 Years ago, thu, may 27, 2010, 12:00:00

I want to copy data from one text box to another in html automatically i.e., as I edit the first text box the second one should reflect the same spontaneously.


More From » javascript

 Answers
1

call javascript function on onkeypresss



function copy_data(val){
var a = document.getElementById(val.id).value
document.getElementById(copy_to).value=a
}


EDITED USE onkeyup or onblur instead





<html>
<head>
<script>
function copy_data(val){
var a = document.getElementById(val.id).value
document.getElementById(copy_to).value=a
}
</script>
</head>
<body>
<input type=text name =a id=copy_from onkeyup=copy_data(this)/>
<input type=text name =a id=copy_to/>
</body>
</html>

[#96665] Tuesday, May 25, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devlin

Total Points: 474
Total Questions: 113
Total Answers: 100

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;