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.
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>