Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: IF/else help

  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IF/else help

    Code:
    <script type="text/javascript">
      var y=prompt("What is your name?")
      alert(y + "?!?!?! Now that's a stupid name, who would ever name there kid that?")
      alert("Just kidding " + y + " is a nice name.")
      var noa=prompt("How many of these do you think there are?",92)
        if (noa > 1000) {
          var x=confirm(noa + "?!?! Am I that rude?")
          if (!x) {
            alert("nah I'm not, it's 1000.")
          }
          else {
            alert("Your Correct I'm not that rude, it's 1000.")
          } 
        else if (noa < 1000) {
          alert("Are you sure?")
          alert("Well your wrong, it's 1000.") /* 6 alerts */
        } 
        else if (noa == 1000) {
          alert("Holy ****.")
          alert("You Guessed right.")
        }
      }
      alert("So your going to be sitting here for a while")
    </script>
    can someone please help me? i know its simple... I'm missing something somewhere... nothing works...
    Last edited by Aceflamer; 10-05-2008 at 06:44 PM.

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    The (FireFox) error console will help you find the syntax error(s). As for the grammatical errors, I'd say you're beyond help.

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arty Effem View Post
    The (FireFox) error console will help you find the syntax error(s). As for the grammatical errors, I'd say you're beyond help.
    grammatical errors? lol

    syntax errors is just the "else" statement, and i can't seem fix it...

  • #4
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Aceflamer View Post
    grammatical errors? lol

    syntax errors is just the "else" statement, and i can't seem fix it...
    Here's the same code laid-out with the brace pairs aligned. You can see there are two consecutive else clauses.
    Code:
    <script type="text/javascript">
      var y=prompt("What is your name?")
      alert(y + "?!?!?! Now that's a stupid name, who would ever name there kid that?")
      alert("Just kidding " + y + " is a nice name.")
      var noa=prompt("How many of these do you think there are?",92)
      if (noa > 1000) 
      {
       var x=confirm(noa + "?!?! Am I that rude?")
       if (!x) 
       {
        alert("nah I'm not, it's 1000.")
       }
       else
        {
         alert("Your Correct I'm not that rude, it's 1000.")
        }
           
      else 
       if (noa < 1000) 
       {
        alert("Are you sure?")
        alert("Well your wrong, it's 1000.") /* 6 alerts */
       } 
        else if (noa == 1000) 
        {
          alert("Holy ****.")
          alert("You Guessed right.")
        }
      }
      
      alert("So your going to be sitting here for a while")
    
    </script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •