View Full Version : newbie needing help (simple i hope)

06-28-2006, 09: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.
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

<title>why why wont it work</title>
<script type = "text/javascript">
var passes=0,
var failures=0,
var student=0,

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;
failure=failures +1;


document.writeln("<h1>examination results</h1>");
if (passes >8)
document.writeln("<br/raise tutition");
<p>click refresh(or reload) to run the script again</p>

06-28-2006, 09:55 PM
first off <script type = "text/javascript"> needs to be changed to
<script language="JavaScript" > so browser can read the java script

06-28-2006, 10:01 PM
This code looks completely wrong , i dont even think this is javascript. Read a book on javascript or google javascript. The way you declared your variables is wrong also..

06-28-2006, 10:07 PM
Thanks, but thats not gonna change anything .
Your way may be the proper way, but the browser picks up the javascript code fine the way i did it.
Even my prof said that it was ..."ook i guess" lol .

Its something in the code itself thats messing it up.

I have spent hours trying to figure it out and it took me way less time to write it.lol. and istill cant figure it out
I looked everything over and over .

if i dont figure it out by tomorrow or someone figures it out for me.
im just gonna hand it in that way lol and hopefully at least get a decent mark for my attempt at writing it.

but thanks anyway for trying to help me. :)

06-28-2006, 10:13 PM
Oh its javascript all right. or my teacher is gone thru the roof. he kinda looks it.
Maybe thats it, my variables are wrong. lol but i went thru them so many times wrote them differently. nothing.

Id say the book i was given but the rules dont allow advertisment.

When i figure it out ill post my findings on here so other can have a hint on whats wrong and whats not.

Thanks again anyway for you help both of you.