Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: WHYY isn't this working?  (Read 3469 times)

0 Members and 1 Guest are viewing this topic.

Google

    Topic Starter


    Mentor

    Thanked: 2
    • Certifications: List
    • Experience: Experienced
    • OS: Windows 7
    WHYY isn't this working?
    « on: November 28, 2009, 01:30:45 PM »
    Code: [Select]
    <html>
    <script type="text/javascript">

    {

    var x=20;
    var y=10;
    if x==20
    {
    document.write("TRUE STATEMENT");
    }
    else
    {
    document.write("FALSE STATEMENT");
    }

    }
    </script>
    </html>

    Why is it not working?? Looks right to me.

    kpac

    • Web moderator
    • Moderator


    • Hacker

    • kpac®
    • Thanked: 184
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: WHYY isn't this working?
    « Reply #1 on: November 28, 2009, 03:31:52 PM »
    Wait, wait and wait. ;D

    Head over to W3Schools and learn HTML first. Then move onto CSS and finally javascript.

    Google

      Topic Starter


      Mentor

      Thanked: 2
      • Certifications: List
      • Experience: Experienced
      • OS: Windows 7
      Re: WHYY isn't this working?
      « Reply #2 on: November 28, 2009, 03:35:38 PM »
      I have already learnt HTML pretty much completely a while ago. And css I know a little of. I'm doing fine with Javascript so far...

      Why is it not working? You want me to put it in <body> of the text, or what are you trying to say here?

      kpac

      • Web moderator
      • Moderator


      • Hacker

      • kpac®
      • Thanked: 184
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 7
      Re: WHYY isn't this working?
      « Reply #3 on: November 28, 2009, 03:39:48 PM »
      A HTML doc needs at least a starting and ending html tag and a starting and ending body tag.

      So yes, you need to put in <body> tag.

      Google

        Topic Starter


        Mentor

        Thanked: 2
        • Certifications: List
        • Experience: Experienced
        • OS: Windows 7
        Re: WHYY isn't this working?
        « Reply #4 on: November 28, 2009, 03:45:28 PM »
        Thanks. OMG guess what I just noticed. I forgot to put the condition [if] in parentheses.
        Whoops, javascript is so specific geez  ;D ;D ;D

        kpac

        • Web moderator
        • Moderator


        • Hacker

        • kpac®
        • Thanked: 184
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 7
        Re: WHYY isn't this working?
        « Reply #5 on: November 28, 2009, 03:49:32 PM »
        Quote
        I forgot to put the condition [if] in parentheses.
        Errr.....

        Quote
        Code: [Select]
        <script type="text/javascript">

        {

        var x=20;
        var y=10;
        if x==20
        {
        document.write("TRUE STATEMENT");
        }
        else
        {
        document.write("FALSE STATEMENT");
        }

        }
        </script>

        You actually put in too many parentheses in there.

        Unless it's a function which will be called later, you can use it this way:
        Code: [Select]
        <script type="text-javascript">
        var x=20;
        var y=10;
        if x==20
        {
        document.write("TRUE STATEMENT");
        }
        else
        {
        document.write("FALSE STATEMENT");
        }
        </script>

        Quote
        javascript is so specific geez
        If that's the case, then forget what I said about learning PHP or ASP.

        Google

          Topic Starter


          Mentor

          Thanked: 2
          • Certifications: List
          • Experience: Experienced
          • OS: Windows 7
          Re: WHYY isn't this working?
          « Reply #6 on: November 28, 2009, 03:53:24 PM »
          Errr.....

          You actually put in too many parentheses in there.

          Unless it's a function which will be called later, you can use it this way:
          Code: [Select]
          <script type="text-javascript">
          var x=20;
          var y=10;
          if x==20
          {
          document.write("TRUE STATEMENT");
          }
          else
          {
          document.write("FALSE STATEMENT");
          }
          </script>
          If that's the case, then forget what I said about learning PHP or ASP.

          Code: [Select]
          <script type="text-javascript">
          var x=20;
          var y=10;
          if (x==20)
          {
          document.write("TRUE STATEMENT");
          }
          else
          {
          document.write("FALSE STATEMENT");
          }
          </script>

          Do I not need parentheses around the condition? Like that.

          if (x==20)

          And I don't mind javascript being specific I actually like it, I just gotta get used to it, and stop making silly mistakes....

          kpac

          • Web moderator
          • Moderator


          • Hacker

          • kpac®
          • Thanked: 184
            • Yes
            • Yes
            • Yes
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 7
          Re: WHYY isn't this working?
          « Reply #7 on: November 28, 2009, 03:58:39 PM »
          Quote
          Do I not need parentheses around the condition? Like that.

          if (x==20)
          Woops sorry. Yes, I didn't notice that. ;D
          That's what happens when you're always copyin' 'n' pastin'.

          Google

            Topic Starter


            Mentor

            Thanked: 2
            • Certifications: List
            • Experience: Experienced
            • OS: Windows 7
            Re: WHYY isn't this working?
            « Reply #8 on: November 28, 2009, 04:05:25 PM »
             ;D