<input type="text" id="t1" name="t1" onkeyup="test(this.value);"/>
<input type="text" id="t2" name="t2"/>
<script type="text/javascript">
function test(vl){
var arr = vl.split('');
if(arr[0] == 'A'){
document.getElementById('t2').value = 'Apple';
}else if(arra[0] == 'B'){
document.getElementById('t2').value = 'Banana';
}else{
document.getElementById('t2').value = 'Foo';
}
}
</script>