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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keeps saying else if is a syntax error

Status
Not open for further replies.

estesflyer

Programmer
Dec 19, 2000
284
US
im starting to get the hang of writing my own simple scripts, but for some reason, this keeps saying that there is a syntax error! its really pissing me off! i also know that the url thing doesnt work, but i can fix that later, i just wanna know whatsup!

<html>
<head>
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
<!--
window.alert(&quot;what do you want to do today, surf the web, or do you want to play a game?&quot;);
var command=window.prompt(&quot;type in surf_web or game_plz.&quot;);
if (command == &quot;surf_web&quot;); {
var location=window.prompt(&quot;what website do you want to go to?&quot;,&quot;type URL here&quot;);
window.open(location,&quot;new_window&quot;,&quot; location=no,status=no,menubar=no,resizable=no,width=500,height=700,scrollbars=auto,directories=no&quot;);
}
else if (command == &quot;game_plz&quot;) {
window.alert(&quot;ok, we can play a game!&quot;);
window.alert(&quot;its not a very fun game, but its the thought that counts right? right??&quot;);
var noun=window.prompt(&quot;give me a noun plz.&quot;,&quot;type noun here&quot;);
var verb=window.prompt(&quot;now give me a verb plz.&quot;,&quot;type verb here&quot;);
var noun2=window.prompt(&quot;finally, plz give me another noun.&quot;,&quot;type noun here&quot;);
var sentence=&quot;the &quot; + noun + &quot; and the monkey &quot; + verb + &quot; over to the &quot; + noun2 + &quot;, and kicked it!&quot;;
window.alert(&quot;that was fun wasn't it! wasn't it?&quot;);
window.alert(&quot;Ok, Since your board of me already, I guess we can just talk later, dat ok? good! ^_^&quot;);
}
//-->
</script>

<title></title>
</head>
</html>
 
Hi estesflyer,

You don't need a semicolon in this line,

if (command == &quot;surf_web&quot;);

that's causing the problem, just remove that semicolon and it should works!

hope this helps, Chiu Chan
cchan@gefmus.com
 
ok, plz ignore this post, for I, Rusty, am the biggest idiot in the world! I just realized that I need to start trying to figure out these problems on my own, instead of getting forum happy. from now on, I will only post code that i REALLY have a problem w/

btw, I fixed that program, its working fine now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top