assistmeandyou
06-28-2006, 08:06 PM
Hello everyone. Im a newbie at javascript and in need of some help.
I read the rules, and i think i can post this i hope.
Yes it is for school, but at least i wrote it myself.
lol
Anyway its a simple program, but im stumped has in why it doesnt work.
This is what happens.
You open the page a box pops up and askes, type in a number 1 for pass,
or 2 for fail ok thats all good.
But its suppose to stop after asking a few times.
whats happens is it just keeps asking for more info.
it doesnt end, even if you click on cancel it just askes again.
And i cant even close the browser either :(
I hope that i explained myself well for you, enough to get some help on it. because im starting to pull my hair out on why i cant get it to work.
did i write it totally wrong ....?is it something simple that im not seeing.
excuse my english im learning quickly.
thanks for any help you can provide me with
<html>
<head>
<title>why why wont it work</title>
<script type = "text/javascript">
<!--
var passes=0,
var failures=0,
var student=0,
result;
while (student<=10){
result=window.prompt("enter result"
+ "(1=pass,2=fail)","1");
while (result !="1" || result !="2")
result = window.prompt(
"incorrect result. please enter 1 for pass"
+"or 2 for fail", "1");
}
if (result== "1")
passes = passes +1;
else
failure=failures +1;
student=student+1;
document.writeln("<h1>examination results</h1>");
document.writeln(
"passed:"+passes+"<br/>failed:"+failures);
if (passes >8)
document.writeln("<br/raise tutition");
//-->
</script>
</head>
<body>
<p>click refresh(or reload) to run the script again</p>
</body>
</html>
I read the rules, and i think i can post this i hope.
Yes it is for school, but at least i wrote it myself.
lol
Anyway its a simple program, but im stumped has in why it doesnt work.
This is what happens.
You open the page a box pops up and askes, type in a number 1 for pass,
or 2 for fail ok thats all good.
But its suppose to stop after asking a few times.
whats happens is it just keeps asking for more info.
it doesnt end, even if you click on cancel it just askes again.
And i cant even close the browser either :(
I hope that i explained myself well for you, enough to get some help on it. because im starting to pull my hair out on why i cant get it to work.
did i write it totally wrong ....?is it something simple that im not seeing.
excuse my english im learning quickly.
thanks for any help you can provide me with
<html>
<head>
<title>why why wont it work</title>
<script type = "text/javascript">
<!--
var passes=0,
var failures=0,
var student=0,
result;
while (student<=10){
result=window.prompt("enter result"
+ "(1=pass,2=fail)","1");
while (result !="1" || result !="2")
result = window.prompt(
"incorrect result. please enter 1 for pass"
+"or 2 for fail", "1");
}
if (result== "1")
passes = passes +1;
else
failure=failures +1;
student=student+1;
document.writeln("<h1>examination results</h1>");
document.writeln(
"passed:"+passes+"<br/>failed:"+failures);
if (passes >8)
document.writeln("<br/raise tutition");
//-->
</script>
</head>
<body>
<p>click refresh(or reload) to run the script again</p>
</body>
</html>