Reputation: 51
I have this code :
<script type="text/javascript">
function GetChar(event) {
var chCode = ('charCode' in event) ? event.charCode : event.keyCode;
if (chCode == 13) {
var textBox = document.getElementById('TEXTBOX');
alert("The text in the box is: " + textBox.value);
document.getElementById('test').innerHTML = ("The text in the box is: " + textBox.value);
if (textBox.value == 'ninja') document.getElementById('teraminal').innerHTML = ("working!")
}
}
</script>
HTML:
<input type="text" id="TEXTBOX" size="40" value="" onKeyPress="GetChar (event);" />
<label id="test"></label>
<textarea rows="40" cols="80" readonly id="terminal" draggable="false" style="resize:none">
I want it to say "working" in the <textarea>
when I type "ninja", but it's not working. Any ideas on how to fix it?
Upvotes: 2
Views: 96
Reputation: 943470
Set the value
property, not the innerHTML
property and spell terminal
consistently.
Upvotes: 3