The problem I am having is that it is out putting employee number not valid while I am typing a valid ID.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript">
<!--



var emp = new Array ("Billy", "Jill", "Wolfgang", "Xavier", "Antoinette","John")
var empNum = new Array (78,90,23,12,56,31)

var i = 0


 
var empSearch = eval(prompt("Please Enter the ID of the employee you are looking for?"));

for(var i = 0; i < empNum.length; i++)
{

 
 if (empNum[i] == empSearch)
 {
 document.write("<br> employee number is valid, this employee is " + emp[i] + "<br>")
 }
   
   else 
   {
   document.write("employee number is not valid")
   }

}
//-->
</SCRIPT>


</BODY>
</HTML>

try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!--
var emp = new Array ("Billy", "Jill", "Wolfgang", "Xavier", "Antoinette","John")
var empNum = new Array (78,90,23,12,56,31)
var i = 0
var empSearch = eval(prompt("Please Enter the ID of the employee you are looking for?"));
for(var i = 0; i < empNum.length; i++)
{

 if (empNum[i] == empSearch)
 {
   document.write("<br> employee number is valid; this employee is " + emp[i] + "<br>");
   break;
 }
 else
 {
 	//document.write("employee number is not valid");
 }
}
//-->
</SCRIPT>
</BODY>
</HTML>

That was the solution I was considering but I need an error message if the ID is not valid.

try this is working:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!--
var emp = new Array ("Billy", "Jill", "Wolfgang", "Xavier", "Antoinette","John")
var empNum = new Array (78,90,23,12,56,31)

var i = 0

 var empSearch = eval(prompt("Please Enter the ID of the employee you are looking for?"));
smsg="";
emsg="";
for(var i = 0; i < empNum.length; i++)
{
if (empSearch!=null && empSearch!="")
 {

 if (empNum[i] == empSearch)
 {
   smsg="<br> employee number is valid; this employee is " + emp[i] + "<br>";
   break;
 }
 else
 {
 	emsg="employee number is not valid";
 }
  }
   
}

if(smsg!="")
document.write(smsg);
else
document.write(emsg);
//-->
</SCRIPT>


</BODY>
</HTML>

That Helped thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.