Hi all,

first off thank you in advance for any help you can offer me. My knowledge of Javascript is limited only to taking other people's hard work and trying to mould it to my whim. In this case, I've failed. I had a friend write me a small piece of coding for something that I'm working on. And it worked great for what I needed. Then I needed to duplicate it, but to no avail. The code is designed so that when a person types a specific set of characters into a text box, it displays the outcome below it. Simple enough. These are 3 digit character sets. Then I wanted to create a second occurance of this for another set of codes, in this case, when you type in the person's name, their phone number is displayed below. For some reason, this time, when you start entering the person's name, the list of variables appears below, but as soon as you enter in the second letter of the person's name, all values dissapear! I'm sure this is a simple fix, but I just can't get it. Can someone help?
----------------------------------------------------

THIS ONE WORKS FINE

<script language="javascript">

data = [
["R34", "Avionics" ],
["512", "Gear" ],
["58C", "Gear" ],
["59C", "Gear" ],
["01R" , "Hardware" ]
];


function search_for_package(e) {
var results = "";
for (var i= 0; i < data.length; i++) {
if (e.value.toUpperCase() == "") {
results = "Enter MRP Code";
break;
}
if (e.value.toUpperCase() == data[i][0].substr(0,e.value.length)) results += data[i][1] + "<br/>";
}
document.getElementById("package").innerHTML = results;
}

</script>

<body>
<input type="text" name="prgr" size=15 id="prgr" style="color: white;" font-weight: bold; onkeyup="javascript:search_for_package(this);"></input>
<div id="package">Enter MRP Code</div>
</body>
-------------------------------------
THIS ONE ONLY WORKS WHEN THE FIRST CHARACTER OF THE NAME IS DISPLAYED
<script language="javascript">

data2 = [
["Paul", "555-898-5879" ],
["Carmen", "555-463-7470" ],
["Charles", "555-786-2322" ]
];


function search_for_employee(e) {
var results = "";
for (var i= 0; i < data2.length; i++) {
if (e.value.toUpperCase() == "") {
results = "Enter Employee Name";
break;
}
if (e.value.toUpperCase() == data2[i][0].substr(0,e.value.length)) results += data2[i][1] + "<br/>";
}
document.getElementById("employee").innerHTML = results;
}

</script>

<body>
<input type="text" name="prgr" size=15 id="prgr" style="color: white;" font-weight: bold;
onkeyup="javascript:search_for_employee(this);"></input>
<div id="employee">Enter Employee Name</div>
</body>