/    Sign up×
Community /Pin to ProfileBookmark

? about this script!

I know little about writing java script, so I use various website to gain the script I want to use. Right now I’m building a Members only site, for a Landlord Orgn. they have compiled what is a TENANT-LANDLORD list they wish to make available to members. I don’t want ppl to be able to see the whole list, They just need to put in a name and check to see if they are on the list. Internal search engines work ok, but they give a link back to the list. I’m useing a java script from a website called “DIRECTORY” from here: [url]http://javascript.internet.com/miscellaneous/directory.html[/url]
Now this script works great, but it only works for letters of the alphabet, so when you check the “A” you receive all names that start with A, When the list comes up all information comes up in a paragraph form. I have tryed to increase the size of the display window hopeing that it would cause each name to be on a single line, like a list.

Is there someplace in the information (names on list) that I should/could be putting a space or caritor to cause this effect?

There are 2000+ names on the list right now and it will increase!

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JAug 06.2004 — Are you wanting just the 1 persons name to be shown?
Copy linkTweet thisAlerts:
@Mr_JAug 06.2004 — I ran this script up as an example for you to try.

Enter any one of the first three names to see display



[SIZE=1]

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>



<script language="javascript">

<!--

contacts=new Array()



contacts[contacts.length]=new Array("Gracie Allen","Bookkeeping, Tel. 234-5678 ext 13")

contacts[contacts.length]=new Array("Harold Ammons","Engineering, Tel. 777-0987 ext 23")

contacts[contacts.length]=new Array("James Atkin","Research and Development, Tel. 777-0933 ext 17")

contacts[contacts.length]=new Array("New Contact","New Contact Information")

contacts[contacts.length]=new Array("New Contact","New Contact Information")

contacts[contacts.length]=new Array("New Contact","New Contact Information")

contacts[contacts.length]=new Array("New Contact","New Contact Information")

contacts[contacts.length]=new Array("New Contact","New Contact Information")

contacts[contacts.length]=new Array("New Contact","New Contact Information")

contacts[contacts.length]=new Array("New Contact","New Contact Information")





function find_person(){

found=0

person=document.forms["f1"].elements["t1"].value.toLowerCase()



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

searching=contacts[i][0].toLowerCase()



if(person==searching){

document.getElementById("display").innerHTML="<b>"+contacts[i][0]+"</b>"

document.getElementById("display").innerHTML+="<BR>"+contacts[i][1]

found=1

}

else{



if(found!=1){

document.getElementById("display").innerHTML="Sorry, <b>"+person+"</b> is not on the list"

}



}



}



}



// -->

</script>



</HEAD>

<BODY>

<center>

<table border="0" width=250px height=200px 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="find_person()">

</form>

</td>

</tr>

<tr>

<td valign="top">

<div id="display"></div>

</td>

</table>

</center>

</BODY>

</HTML>









[/SIZE]
Copy linkTweet thisAlerts:
@CNNSOSauthorAug 06.2004 — If there are 5 different "Adams" it would show all 5.

I pasted your script in a new documet and this is the error I get

An error has occured in the scripting

LINE: 64

CHAR: 1

ERROR: Object expected

CODE: 0

Did I forget to do something?

OPPS IC I recopied and pasted its working, I need to add contacts then I'll get back to you!
Copy linkTweet thisAlerts:
@CNNSOSauthorAug 06.2004 — OH WOW that works great! Thank You. Guess I have a lot of typing to do, with over 2000 names on the list, LOL

If theres anything I can do for you, let me know, I'd be more than happy to donate to you, if so.

Thanks again.
Copy linkTweet thisAlerts:
@CNNSOSauthorAug 06.2004 — OK I just ran into one problem, when I have 2 identical names, it will only show one of the names,
Copy linkTweet thisAlerts:
@Mr_JAug 06.2004 — If you have 2000 entries to do in the array try out my array creator

www.huntingground.freeserve.co.uk/scripts/arrayc_mult.htm

As for the amended script please try the following.

[SIZE=1]

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>



<script language="javascript">

<!--

contacts=new Array()



contacts[contacts.length]=new Array("Gracie Allen","Bookkeeping, Tel. 234-5678 ext 13")

contacts[contacts.length]=new Array("Harold Ammons","Engineering, Tel. 777-0987 ext 23")

contacts[contacts.length]=new Array("James Atkin","Research and Development, Tel. 777-0933 ext 17")

contacts[contacts.length]=new Array("New Contact","New Contact Information1")

contacts[contacts.length]=new Array("New Contact","New Contact Information2")

contacts[contacts.length]=new Array("New Contact","New Contact Information3")

contacts[contacts.length]=new Array("New Contact","New Contact Information4")

contacts[contacts.length]=new Array("New Contact","New Contact Information5")

contacts[contacts.length]=new Array("New Contact","New Contact Information6")

contacts[contacts.length]=new Array("New Contact","New Contact Information7")





function search_data(){

count=0

temp=new Array()

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){

temp[count]=i

count++

}



}



for(j=0;j<temp.length;j++){

document.getElementById("display").innerHTML+=contacts[temp[j]][0]+"<BR>"

document.getElementById("display").innerHTML+=contacts[temp[j]][1]+"<BR><BR>"

}



if(temp.length==0){

document.getElementById("display").innerHTML="Sorry, <b>"+locating.toUpperCase()+"</b> is not on the list"

}

}



// -->

</script>



</HEAD>

<BODY>

<center>

<table border="0" width=250px height=200px 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()">

</form>

</td>

</tr>

<tr>

<td valign="top">

<div id="display"></div>

</td>

</table>

</center>



</BODY>

</HTML>



[/SIZE]
Copy linkTweet thisAlerts:
@CNNSOSauthorAug 07.2004 — I could not get this script to work. When opening the search page up got error,

line 330

char 64

Error Expected ')'

Code 0

This is line 330:

contacts[contacts.length]=new Array("Gilmore, Steven", "Lloyd & Karen Latham, TEL:624-4289")

I can't see anything different about the line then from any of the others I have.

When you type in a name in the search box and clk FIND nothing happens.

Thank You
Copy linkTweet thisAlerts:
@Mr_JAug 07.2004 — Have you tried the script on it's own?

Also you cannot go

Gilmore, Steven

it has to be

Steven Gilmore

ChristianName SirName
Copy linkTweet thisAlerts:
@CNNSOSauthorAug 07.2004 — I must have really messed something up, can't get either one of them to work now. Is there an email address I could send the page to for you to look at and see where I went wrong?

I'm going to still keep trying to straighten it out. Try to find what I did wrong
Copy linkTweet thisAlerts:
@CNNSOSauthorAug 07.2004 — MR J I Found the problem, got it straight. I was looking at the information that the error gave me. That info was correct, it was the line infront of that line that was incorrect or had the mistake in it.

If I'm understanding the script right, the names do not have to be in alphabetical order.

Works great now.
Copy linkTweet thisAlerts:
@Mr_JAug 07.2004 — I'm glad you found the problem.

Just out of interest I have changed the display side of the script which looks a bit neater.

You can see 2 examples here

www.huntingground.freeserve.co.uk/scripts/contacts.htm
×

Success!

Help @CNNSOS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...