Oz Nerf - Australian Nerf Community

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Oz Nerf - Australian Nerf Community

Nerfing down under!. Oz Nerf - Australian Nerf Community

If you're new to the forums please do the following.
1. Read the Forum Rules before posting!
2. Update your location, age and avatar TRUTHFULLY
3. Introduce yourself in the Welcome to Oznerf forum section =)

Navigation

Statistics

Our users have posted a total of 52416 messages in 3425 subjects

We have 1922 registered users

The newest registered user is seabulb

Latest topics

» gold coast nerf war?
by ShaGGz LMS Fri Oct 07, 2016 3:49 pm

» nerf clearout
by Runeblade Wed Sep 07, 2016 7:03 am

» How to replace the Longshot trigger plate?
by neon64bit Mon Jan 04, 2016 9:42 am

» Mid North Coast/Hunter War Organisation
by Vampros Thu Dec 31, 2015 6:18 pm

» WTB felt for slugs
by Richo123 Sat Oct 24, 2015 6:21 am

April 2024

MonTueWedThuFriSatSun
1234567
891011121314
15161718192021
22232425262728
2930     

Calendar Calendar


    Javascript Question - URGENT!

    Switchblade
    Switchblade


    Posts : 232
    Join date : 2010-08-05
    Age : 30
    Location : Brisbane Represent!

    Javascript Question - URGENT! Empty Javascript Question - URGENT!

    Post  Switchblade Wed Jun 01, 2011 7:11 am

    so I'm trying to make a small javascvript file. However when i run the page in FF, the promptbox appears, and yes, I do have javascript enabled. But yeah, it doesn't run, yet if I take out the switch and the else at teh bottom, it runs aswell.

    Also, for the id numbe,r I can put in any length number, aslong as it's even, what it should do is only allow it if it's even, and exactly 4 integers.

    Lastly, the roster thing, i can input any number into that :? HELP PLEASE.
    P.s. this is using xhtml 1.0 strict.

    Code:

    <script type = "text/javascript">
    /* <![CDATA[ */
    var id, weeklyroster;


    id = (window.prompt("Employee id","0"));

    function vid(id)
    {
    if (isNaN(id))
       {
       window.alert("This is not a valid id number, please enter a valid id.")
       return false;
       }
    else if (!(id%2==0 ||id.length==4))
          {
          alert("This id is not valid.  Please try again");
         return false;
          }
      else
          {
          alert("This is a valild id");
         return true;
          }
     


    if (vid(id))
    {
    window.prompt("First name");
    window.prompt("Last name");
    weeklyroster = parseInt(window.prompt("What rotation are you on the roster? 1, 2, 3 or 4?","0"));

       while
       (weeklyroster < 1 || weeklyroster > 4 );
       {
       weeklyroster = parseInt(window.prompt("What rotation are you on the roster? 1, 2, 3 or 4?"));
       }

       
       switch (weeklyroster)
       {
       case 1:
          for (i=0;<=5;i++)
             document.write("Task No: " + i);
             document.write("<br />");
          break;

       case 2:
          for (i=5;<=10;i++)
             document.write("Task No: " + i);
             document.write("<br />");
          break;
        
       case 3:
          for (i=15;<=20;i++)
             document.write("Task No: " + i);
             document.write("<br />");
          break;

       case 4:
          for (i=20;<=20;i++)
             document.write("Task No: " + i);
             document.write("<br />");
          break;
          
       default:
             document.write("This is an invalid selection.")
             document.write
       }
       
    else{
    alert("invalid id")
    }

    }
       
    /* ]]> */
    </script>
    </head>


    <body>
    <h1>Employee task generator</h1>
    <script type = "text/javascript">
    function id()
    </script>

      Current date/time is Fri Apr 26, 2024 6:40 pm