View Full Version : It seems like its ignoring my script
imemyself
09-13-2002, 02:40 AM
I've made a java script and it seems like the computer is ignoring it. Nothing from it will show up or do anything. Heres part of it
<BODY>
<H1 ALIGN=CENTER>Calculator</h1>
<SCRIPT>
var n1 = prompt("Number One","N1");
var n2 = prompt("Number Two","N2");
var op = prompt("Mathematical Operation (A for add S for subtract M for multiply D for divide","Operator");
var OK = confirm("This will start the calculations, press OK to proceed");
Can anyone help me?
Spookster
09-13-2002, 03:00 AM
This will explain why:
http://javascriptkit.com/javatutors/alert2.shtml
imemyself
09-13-2002, 09:55 PM
I looked through it and I didn't see anything telling me why
dagaffer
09-13-2002, 10:33 PM
have you got the rest of the script or is that the whole thing...?
joh6nn
09-13-2002, 10:34 PM
did you close the <Script> tag?
also, can we see the rest of the page? it's easier to figure out why it's not working, when we can see all of the code.
imemyself
09-14-2002, 12:41 AM
Heres all the script
<SCRIPT>
var n1=window.prompt("Number One");
var n2=window.prompt("Number Two");
var op=window.prompt("Mathematical Operation (A for add S for subtract M for multiply D for divide");
var answer
var type
If (op=="A");
{
answer=n1+n2;
type="sum";
}
If (op=="S");
{
answer=n1-n2;
type="difference";
}
If (op=="M");
{
answer=n1*n2;
type="product";
}
If (op=="D");
{
answer=n1/n2;
type="dividend";
}
alert("The "+type+" is"+answer" .");
</SCRIPT>
I changed it a little when I was trying to get it to work.
adios
09-14-2002, 12:45 AM
IF :(
JS is case-sensitive....
if
imemyself
09-14-2002, 12:51 AM
:o Still doesn't work even with correct Ifs.:mad:
adios
09-14-2002, 12:54 AM
Where are 'n1' and 'n2' defined?
imemyself
09-14-2002, 02:38 AM
I guess I forgot to change all the variables when I seeing if I could get it to work.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.