Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translator Fixed rac2

Status
Not open for further replies.

LadyClaire

Technical User
Dec 10, 2002
26
0
0
US
Ok I have the single words translation fixed. Just added a lil text to seperate the english translator from the elvish translator and it works fine. I didnt even have to use the following code:

target == elvishWords ){
document.elveng.english.value = englishWords;

Now about the phrase translations. I got a little confused on that so thought best to start a new thread with that. That which we are we are, made weak by time and fate, but strong in mind to try, to seek, to find, but not to yield.
 
Sureyou can get it yourself at

or here it is:

<html>
<head>
<title>English-Elvish Translator</title>
<script src=&quot;dictionary.js&quot;></script>

<script>
function trElvishEnglish(){
var found = false;
var target = document.elveng.elvish.value;
for(var i=0;i<elvishWords.length;i++){
if( target == elvishWords ){
document.elveng.english.value = englishWords;
found = true;
break;
}
}
if( found == false ){
document.elveng.english.value = &quot;Sorry, that word is not in the dictionary&quot;;
}
}
</script>

<script>
function trEnglishElvish(){
var found = false;
var target = document.engelv.english.value;
for(var i=0;i<englishWords.length;i++){
if( target == englishWords ){
document.engelv.elvish.value = elvishWords;
found = true;
break;
}
}
if( found == false ){
document.engelv.elvish.value = &quot;Sorry, that word is not in the dictionary&quot;;
}
}
</script>

</head>
<BODY background=&quot;stonewall.jpg&quot;>

<center><font color=&quot;#00CC00&quot;><font size=+2>English-Elvish Translator</font></font></center>

<p><font color=&quot;#00CC00&quot;>Please Type English Word:&nbsp;</font><form name=&quot;engelv&quot;><input type=&quot;text&quot; name=&quot;english&quot;>&nbsp&nbsp&nbsp&nbsp<input type=&quot;button&quot; value=&quot;Please Translate&quot; onclick=&quot;trEnglishElvish()&quot;>
<p><font color=&quot;#00CC00&quot;>Elvish Translation:&nbsp;</font><input type=&quot;text&quot; name=&quot;elvish&quot;></form>
<br>
<p><font color=&quot;#00CC00&quot;>Please Type Elvish Word:</font><form name=&quot;elveng&quot;><input type=&quot;text&quot; name=&quot;elvish&quot;>&nbsp&nbsp&nbsp&nbsp <input type=&quot;button&quot; value=&quot;Please Translate&quot; onclick=&quot;trElvishEnglish()&quot;>
<p><font color=&quot;#00CC00&quot;>English Translation:&nbsp;</font><input type=&quot;text&quot; name=&quot;english&quot;></form>
</BODY>
</html>
That which we are we are, made weak by time and fate, but strong in mind to try, to seek, to find, but not to yield.
 

Check out the source code. :) Keep what you want, ask where you don't understand.

What I did.

1. I formatted the dictionnary to take up 30kb instead of 104kb
2. I consolidated the translating function to easily add a sentence translation
3. added the sentence translation functions
4. kept all the code to a bare minimum Gary Haran
 
Ok now I feel stupid! Your page is set up in frames yes? Well seems you accomplished in a few minutes what I have been working on for a few months. I'll definately have to pick your code apart and figure out what you did exactly. I'm better at doing that than starting from scratch anyway. Thanks Xutopia. But at least I can say I worked hrd on mine getting it to work right. That which we are we are, made weak by time and fate, but strong in mind to try, to seek, to find, but not to yield.
 
Claire,

I've been working with Javascript for almost 10 years and started out looking at other people's code.

If you have any questions on the way I did the thing just ask and i'll explain with pleasure! :) Gary Haran
 
Thanks, I am also a learner by looking. They didnt teach javascript when I was taking my programming classes. All we had was COBOL, C, C++, and VB. I taught myself html over the internet. Same way I am learning JS. Now they have one full class on just Javascript but I cant take it. Dont have the time to plus its not required for my degree. I'll pick through your code tomarrow and see what I can and cant figure out. Post questions if I have any. That which we are we are, made weak by time and fate, but strong in mind to try, to seek, to find, but not to yield.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top