here is my code
</script>
function myFunction() {
var a = ["a.m.","p.m","u.k."];
var b = ["its_morning","its_noon","unKnown_thing"];
var str = document.getElementById("textBox1").value;
for (var k = 0; k < a.length; k++) {
str = str.replace(a[k], b[k]);
};
document.getElementById('textBox2').value = str;
}
</script>
<body>
<textarea onkeyup="myFunction();"id="textBox1"></textarea>
<TEXTAREA type="text" id="textBox2"></TEXTAREA>
</body>
when i type 'a.m.' its working fine but when i type it again its not changing . like:
'a.m. hello world a.m.'
gives results
'its_morning hello world a.m.'
here the last 'a.m.' must be replaced but i dont know wats wrong with it
please answer in javascript ,im not familiar with jquery.