Hello everyone! I'm newbie here and need some help. Could anyone help with javascript? I have two <textarea> tegs that chenges dynamically... When we enter something in first field, automaticaly changes second. But I have some problems with that: When I go to second line of first field second filed does not follow... I need second field to move with first and when someone enters something in the first field, to change second too...
Do you mean that every keypress in the first window triggers the second to update, or just when they enter something and click a button? Can you post the relevant portions of the code?
you could probably just use onkeyup="document.getElementById('second_text_area').innerHTML = this.innerHTML" however this may have some performance issues for longer texts **** Decided to make a test page for this and found out my solution doesn't work at all....probably the same thing you already had
That works if you use .value instead. <textarea height=5 width=50 onkeyup="document.getElementById('second_text_area').value = this.value"></textarea> <textarea height=5 width=50 id="second_text_area"></textarea> Code (markup): It's really choppy, though.
No, I don't mean each character, I mean each line.... I've got some hash function... And want to hash every line in the first <textarea> tag... When we enter something in the first line of firsst textarea to hash it and we move to second line we want live second textarea's first line hashed and go to second line an hash again...
alright.. so whenever the user hits enter you want the second textarea updated? so just check for the enter key before the update happens.. <textarea height=5 width=50 onkeyup="if(isEnter(event)){document.getElementById('second_text_area').value = this.value}"></textarea> <textarea height=5 width=50 id="second_text_area"></textarea> <script type="text/javascript"> function isEnter(evt) { evt = (evt) ? evt : event; var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode); if (charCode == 13) { return true; } else { return false; } } </script> Code (markup):