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 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What is wrong with this?

    Hi once again,

    What is wrong with this code, please? I have tried every possible combination. Half of it is right. The part that is wrong is when you click on cancel, and the next box comes up saying "That's great". It's supposed to pop up saying "oh, that's a shame".

    What I am not sure of is the calling function. Your input and advise would be really appreciated.
    Thanks
    Michelle

    <html>
    <head>
    <title> Would you like some coffee?</title>

    <script type="text/javascript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS

    function coffee () {

    window.confirm("Would you like a cuppa?");

    if (answer="true")
    window.alert("That's great");


    else {
    (answer="false")
    window.alert("Oh, that's a shame");

    }
    }

    //STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </script>

    </head>
    <body>

    <p> Invitation </p>

    <script type="text/javascript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS

    coffee("window.confirm");

    // STOP HIDING FROM INCOMPATIBLE BROWSERS-->
    </script>
    </body>
    </html>

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Code:
    function coffee () {
      var answer = window.confirm("Would you like a cuppa?");
      if (answer) { //OK
        window.alert("That's great");
      }
      else { //Cancel
         window.alert("Oh, that's a shame");
      }
    }
    ...
    coffee();

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Hi glenngv

    thanks so very much for your help.
    I can see myself posting heaps more. JS is a challenge!
    Thanks again
    Michelle.


  •  

    Posting Permissions

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