Alright, first off, I thank anyone who looks at this code and tries
to help me out in advance. Anywho, pretty much this script was
developed for me to study my German vocab easier and faster. It
worked out great to start, but than I started making it more user
friendly. I did a little something to tweak it a bit, and now it
just messes up. It works like this:
1) Asks you what language you are studying (this doesn’t really do
much)
2) Asks how many words you need to study
3) Declares the arrays (English and German)
4) The loop begins
5) Asks for the English word and stores in English array
6) Asks for the previously declared language word for the english
word and stores it in the German Array
7) Stores all the words in a variable with an ‘=’ seperating the
English word from the foriegn language one
8) Loop ends
9) Displays confirm box, with OK being to go on and CANCEL being
start over, with all the words displayed
10) Script ends
Also, anytime a prompt comes up, you can hit the cancel button
or leave it empty to quit, or start over. Now for the problem,
after you type in the first English word and hit enter, or ok, the
script stops running. I thought maybe I inserted and extra ‘}’ to
stop the function, but I don’t see how that would be, since an
error would than occur. I use the latest IE browser, so if the
script has an error it alerts me, and I do not get one.
Well here is the code:
<script language=”Javascript”>
<!–
function set()
{
var exit=5;
var wrds=”;
var l=prompt(‘What language are you studying for?’,’German’);
if ((l==null)||(l==”)||(l==’ ‘)){
set();}
var y=prompt(‘How many words?’,”);
if (y<1){
if (confirm(‘OK = Quitn Cancel = Start Over’)){
return -exit;}else{
set();}}
alert(y);
//declares arrays and length
var english=new Array(y);
var german=new Array(y);
for (var x=1;x<=y+1;x++)
{
english[x]=prompt(‘What is English word number ‘+x+’?’,”);
//verifies something is entered and if to quit
if ((english[x]==null)||(english[x]==”)||(english[x]==’ ‘)){
if (confirm(‘ OK= Quitn Cancel = Start Over’)){
alert(english[x]);
return -x;
break;
}else{
set();
}}
german[x]=prompt(‘What is the ‘+w+’ word for ‘+english[x]+’?’,”);
//verifies something is entered and if to quit
if ((german[x]==null)||(german[x]==”)||(german[x]==’ ‘)){
if (confirm(‘ OK= Quitn Cancel = Start Over’)){
return -x;
break;
}else{
set();
}}
wrds=wrds+english[x]+’ = ‘+german[x]+’n’;
}
alert(english[0]/german[0]);
if(confirm(‘English = Germannn’+wrds)){
game();
}else{
set();
}
}
–>
</script>
If you want to see the whole thing in action go to [url]http://svenssonr.tripod.com/act.htm[/url].