I have two input type = text. The text of the textbox is populated from a custom date picker module. I want to change the content of second text box when the text of first text box is changed.
<input type = "text" id = "one">
<br>
<input type = "text" id = "two">
<br>
<button onclick="myFunction()">Click me</button>
Javascript
function myFunction()
{
document.getElementById('two').value = 'hello';
}
Here I have just simulated the change of textbox ‘two’ on button click but actually it is changed by some other methods.
I want to change the text of textbox ‘one’ when value of textbox ‘two’ is changed.
Events like onchange and keyup wont work as the text is explicitly changed.
Checking the value of both text boxes for equality at interval of 1 sec is also not an option for me.
Plain Javascript or jQuery is fine.
My solution is built on two javascript functions as follows:
here is the HTML:
The following is a demo: http://jsfiddle.net/saidbakr/hD6Sx/