I am trying to write a basic JavaScript code which would act as a 'translator'. For instance certain strings in the input text-box would correspond to specific strings in the output paragraph. So, for example if the word 'x' corresponds to the word 'y', then I want a code so that whenever it finds the word 'x' in the input it will replace it with the word 'y' in the output paragraph.
What would be the simplest way to implement this? And, if there happens to be a large number of translation pairs, what would be the most efficient way of listing them?
Any guidance would be greatly appreciated.
EDIT:
This is how I defined the elements within the code so far:
<script type="text/javascript">
function write_word(){
var trans_parra = document.getElementById('trans');
var word = document.getElementById('word');
var eng = document.getElementById('input');}
</script>
And in the html body:
<p align="center"><input type="button" value="Search" onclick="write_word();"/>