Click to enter a sample name
Jeff Wilkins William Smith New Contact
| Example 1 | Example 2 |
If there are duplicate names in the list, example 1 will show the relevant information in a scrollable display whereas example 2 will show each one individually.
Click on a found name to start an email.
The information is stored in a multi-dimensional array
["Name","Email Address","Contact Information 1"],
["Name","Email Address","Contact Information 2"],
Code for example 1
<script type="text/javascript">
<!--
contacts=[
["Name 1","Email Address 1","Contact Information 1"],
["Name 2","Email Address 2","Contact Information 2"],
["Name 3","Email Address 3","Contact Information 3"],
["Name 4","Email Address 4","Contact Information 4"],
["Name 5","Email Address 5","Contact Information 5"],
["Name 6","Email Address 6","Contact Information 6"],
["Name 7","Email Address 7","Contact Information 7"] // no comma at end of last index
]
function search_data(){ // find multiple occurances of same name
found=false
document.getElementById("display").innerHTML=""
locating=document.forms["f1"].elements["t1"].value.toLowerCase()
for(i=0;i<contacts.length;i++){
located=contacts[i][0].toLowerCase()
if(locating==located){
document.getElementById("display").innerHTML+="<b><a href=\"mailto:"+contacts[i][1]+"\">"+contacts[i][0]+"</a></b><br>"
document.getElementById("display").innerHTML+=contacts[i][1]+"<br>"
document.getElementById("display").innerHTML+=contacts[i][2]+"<br><br>"
found=true
}
}
if(!found){
document.getElementById("display").innerHTML="Sorry, <b>"+locating.toUpperCase()+"</b> is not on the list"
}
}
// -->
</script>
<table border="0" width=250px height=170px style="border:2px ridge #8e8462;font-size:12px">
<tr>
<td valign="top" height="30">
<form name="f1">
<input type"text" name="t1" onclick="this.select()">
<input type="button" value="Find" onclick="search_data()" style="width:80px">
</form>
</td>
</tr>
<tr>
<td valign="top"><div id="display" style=" height:100px;overflow:auto"></div></td>
</table>
Code for example 2
<script type="text/javascript">
<!--
contacts=[
["Name 1","Email Address 1","Contact Information 1"],
["Name 2","Email Address 2","Contact Information 2"],
["Name 3","Email Address 3","Contact Information 3"],
["Name 4","Email Address 4","Contact Information 4"],
["Name 5","Email Address 5","Contact Information 5"],
["Name 6","Email Address 6","Contact Information 6"],
["Name 7","Email Address 7","Contact Information 7"] // no comma at end of last index
]
last_locate=""
function search_data2(){
document.getElementById("display2").innerHTML=""
document.getElementById("more").style.visibility="hidden"
locating=document.forms["f2"].elements["t1"].value.toLowerCase() // name to find
if(locating==""){return}
if(locating!=last_locate){ // if finding new name
count= -1
temp=new Array()
for(i=0;i<contacts.length;i++){ // iterate through array
located=contacts[i][0].toLowerCase()
if(locating==located){ // if name found
count++
temp[count]=i // add to temp array
total_count=0
}
}
}
if(temp.length!=0){ // display name and info, if identical name iterate through names and info
document.getElementById("display2").innerHTML+="<b><a href=\"mailto:"+contacts[temp[total_count]][1]+"\">"
+contacts[temp[total_count]][0]+"</a></b><br>"
document.getElementById("display2").innerHTML+=contacts[temp[total_count]][1]+"</a></b><br>"
document.getElementById("display2").innerHTML+=contacts[temp[total_count]][2]+"<br><br>"
if(temp.length>1){
document.getElementById("more").style.visibility="visible"
document.getElementById("more").innerHTML="Displaying "+(total_count+1)+" of "+temp.length
}
total_count++
if(total_count>temp.length-1){
total_count=0
}
}
if(temp.length==0){ // if no name
document.getElementById("display2").innerHTML="Sorry, <b>"+locating.toUpperCase()+"</b> is not on the list"
}
last_locate=locating
}
// -->
</script>
<table border="0" width=250px height=170px style="border:2px ridge #8e8462;font-size:12px">
<tr>
<td valign="top" height="30">
<form name="f2">
<input type"text" name="t1" onclick="this.select()">
<input type="button" name="b1" value="Find" onclick="search_data2()" style="color:#00aa00;font-weight:bold;width:80px">
</form>
<div id="more" style="color:#ff0000;visibility:hidden"> </div>
</td>
</tr>
<tr>
<td valign="top"><div id="display2"></div></td>
</tr>
</table>