return in text causes reload
I want an interactive text screen: you type in box A, it replies in box B. When you've finished typing there are two ways you could tell it to process your input: either a separate button, or just detecting onChange for the text field. But my problem is that Return/Enter to get out of the text field often (but not always) causes the reply box to reload its initial value.
In this the "echo" button always works, and so does tab to trigger onChange, but using return often (under conditions I don't understand) causes the echoed message to be replaced by "initial value". I've tried all sorts of fixes, such as putting the initial value in the
<script>
function EchoInput () {
document.myform.replybox.value = document.myform.inputbox.value;
}
</script>
<form name="myform">
<input type="text" name="inputbox" onChange="EchoInput()" />
<input type="button" value="echo" onClick="EchoInput()" />
<textarea name="replybox">
initial value
</textarea>
</form>
In this the "echo" button always works, and so does tab to trigger onChange, but using return often (under conditions I don't understand) causes the echoed message to be replaced by "initial value". I've tried all sorts of fixes, such as putting the initial value in the
body onLoad, but none made a difference. How do I stop or trap this?