Click to See Complete Forum and Search --> : Why wont my search funktion work?
Hypercite
01-07-2004, 10:05 AM
Hey all internet lovers...hehe
Well ive been trying to get a search funktion on my page.
I acctualy succeded to get it up, but you cant search.
Someone please help, the web page is: www.elev.solberga.se/kreja
Just go to the search page and pic up the source code.
What am i supposed to edit so that it will work?.
Ps. I use frontpage.
Hypercite
01-07-2004, 10:07 AM
ill just give you the script.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Search</title>
</head>
<body background="../../images/grund/main.gif">
<script language="javascript">
var key = "";
function makeEntry (){
this.Name="";
this.URL = "";
this.Desc = "";
this.Category = "";
return this;
}
function makeArray(n) {
this.length = n;
for (var k = 1; k <= n; k++) {
this[k] = "";
}
return this;
}
function makeLinks(size) {
this.length = size;
for (var r=1; r<= size; r++) {
this[r] = new makeEntry();
this[r].Name = namesArray[r];
this[r].URL = urlsArray[r];
this[r].Desc = descArray[r];
}
return this;
}
var linksize=0
datesArray = new makeArray(linksize);
namesArray = new makeArray(linksize);
urlsArray = new makeArray(linksize);
descArray = new makeArray(linksize);
var arraycount=0
arraycount += 1
urlsArray[arraycount] = "http://www.elev.solberga.se/kreja/index/main/contact/contact.htm"
namesArray[arraycount] = "Contact"
descArray[arraycount] = "contact, phone, email, home"
arraycount += 1
urlsArray[arraycount] = "http://www.elev.solberga.se/kreja/index/main/kreja/kreja.htm"
namesArray[arraycount] = "Kreja"
descArray[arraycount] = "kreja, founder, owner, home,"
linksize = arraycount;
// ----end data -------
function searchLinks(links, keyword){
document.write("<BODY BGCOLOR='#FFFFFF' TEXT='#000000' LINK='#FF0000' VLINK='000080' ALINK='000080'>")
document.write("Search results for keyword: <strong>" +keyword +"</strong><br><br>");
for (var q=1; q<=links.length; q++) {
if (links[q].URL.toLowerCase().indexOf(keyword) != -1){
document.write("<a href=" + links[q].URL +">" + links[q].Name + "</a> - ");
document.write( links[q].Desc + "<br>");
continue;
}
if (links[q].Desc.toLowerCase().indexOf(keyword) != -1) {
document.write("<a href=" + links[q].URL +">" + links[q].Name + "</a> - ");
document.write( links[q].Desc + "<br>");
continue;
}
if (links[q].Name.toLowerCase().indexOf(keyword) != -1) {
document.write("<a href=" + links[q].URL +">" + links[q].Name + "</a> - ");
document.write( links[q].Desc + "<br>");
continue;
}
}
}
</script>
<form name="form">
Search:<br><input type="text" size=50 name="search"><br>
<input type="button" name="submit" value="Search" onClick="validate_form()"><input type="reset" name="reset" value="Clear"></form>
<script>
function validate_form() {
txt = document.form.search.value;
if (txt.indexOf(".") != -1){
alert("Search is invalid! Contains a '.'"); return;}
if (txt.indexOf(",") != -1){
alert("Search is invalid! Contains a ','"); return;}
if (txt.indexOf("@") != -1){
alert("Search is invalid! Contains a '@''"); return;}
if (txt.indexOf("!") != -1){
alert("Search is invalid! Contains a '!''"); return;}
if (txt.indexOf("#") != -1){
alert("Search is invalid! Contains a '#''"); return;}
if (txt.indexOf("$") != -1){
alert("Search is invalid! Contains a '$''"); return;}
if (txt.indexOf("%") != -1){
alert("Search is invalid! Contains a '%''"); return;}
if (txt.indexOf("^") != -1){
alert("Search is invalid! Contains a '^''"); return;}
if (txt.indexOf("&") != -1){
alert("Search is invalid! Contains a '&''"); return;}
if (txt.indexOf("*") != -1){
alert("Search is invalid! Contains a '*''"); return;}
if (txt.indexOf("(") != -1){
alert("Search is invalid! Contains a '(''"); return;}
if (txt.indexOf(")") != -1){
alert("Search is invalid! Contains a ')''"); return;}
if (txt.indexOf("[") != -1){
alert("Search is invalid! Contains a '[''"); return;}
if (txt.indexOf("]") != -1){
alert("Search is invalid! Contains a ']''"); return;}
if (txt.indexOf(";") != -1){
alert("Search is invalid! Contains a ';''"); return;}
if (txt.indexOf(":") != -1){
alert("Search is invalid! Contains a ':''"); return;}
if (txt.indexOf("<") != -1){
alert("Search is invalid! Contains a '<''"); return;}
if (txt.indexOf(">") != -1){
alert("Search is invalid! Contains a '>''"); return;}
if (txt.indexOf("?") != -1){
alert("Search is invalid! Contains a '?''"); return;}
if (txt.indexOf("-") != -1){
alert("Search is invalid! Contains a '-''"); return;}
if (txt.indexOf("=") != -1){
alert("Search is invalid! Contains a '=''"); return;}
if (txt.indexOf("+") != -1){
alert("Search is invalid! Contains a '+''"); return;}
else {
jsi = new makeLinks(linksize);
searchLinks(jsi, txt);
document.write("<br><hr><br>;");
document.write("<a href='search.htm'>Back</a><br>;");
}
}
</script>
</body>
</html>
Pittimann
01-07-2004, 10:34 AM
Hi!
The main point:
please replace all &lt; with < and all &gt; with >
The other thing is the case sensivity with your keywords, I was about to post to your other thread dealing with that search, but had no time :(
If you replace your whole searchLinks function with something like that, it doesn't matter whether you (in the arrays) or the user (in the textfield) use upper or lower case letters:
function searchLinks(links, keyword){
document.write("<BODY BGCOLOR='#FFFFFF' TEXT='#000000' LINK='#FF0000' VLINK='000080' ALINK='000080'>")
document.write("Search results for keyword: <strong>" +keyword +"</strong><br><br>");
for (var q=1; q <=links.length; q++) {
if (links[q].URL.toLowerCase().indexOf(keyword.toLowerCase()) != -1){
document.write("<a href=" + links[q].URL +">" + links[q].Name + "</a> - ");
document.write( links[q].Desc + "<br>");
continue;
}
if (links[q].Desc.toLowerCase().indexOf(keyword.toLowerCase()) != -1) {
document.write("<a href=" + links[q].URL +">" + links[q].Name + "</a> - ");
document.write( links[q].Desc + "<br>");
continue;
}
if (links[q].Name.toLowerCase().indexOf(keyword.toLowerCase()) != -1) {
document.write("<a href=" + links[q].URL +">" + links[q].Name + "</a> - ");
document.write( links[q].Desc + "<br>");
continue;
}
}
}
Please make sure to have "<" in the loops above that function!
Cheers - Pit
Hypercite
01-08-2004, 10:58 AM
Hey the searchfunktion works now.
But try it out (www.elev.solberga.se/kreja) (under search)
When ever you search on something the background off the next page is white.
What can i do to make the background have the same color as the page before?.
Ps.Go to the page and get the source code and youll find that the funktion generates a new page for every search. Thats the page i want to have a soecific bakroud color on.
Cheers
Pittimann
01-08-2004, 11:07 AM
Hi!
Please check out the line:
document.write("<BODY BGCOLOR='#FFFFFF' TEXT='#000000' LINK='#FF0000' VLINK='000080' ALINK='000080'>")
in your search file.
Replace it with
document.write("<BODY BGCOLOR='#FFFFFF' TEXT='#000000' LINK='#FF0000' VLINK='000080' ALINK='000080' background='../../images/grund/main.gif'>")
That should do the job...
Cheers - Pit
Hypercite
01-08-2004, 01:01 PM
Thanx ALOT
now it works nicley.
Pittimann
01-08-2004, 01:17 PM
Hi!
You are welcome!!
By the way, you still have errors un your page_lankar.htm
On top, it says
<SCRIPT language="JavaScript">
var images = new Array();
for(var x=0;x<8;x++){
images[n]= new
Image(); images[n].src = "button-down_"+n+".gif"; }
</SCRIPT>
You better replace that with:
<script language="JavaScript" type="text/javascript">
<!--
var images = new Array();
for(var x=0;x<8;x++){
images[x]= new Image(); images[x].src = "button-down_"+x+".gif"; }
//-->
</script>
Cheers - Pit
Hypercite
01-08-2004, 01:31 PM
okay thanx a buch
But i noticed something
and i thought what the hell?
Open my page www.elev.solberga.se/kreja
now move your mouse up and down as fast as you can over the left side of the page. (the laft side= over the buttons and the blue circle)
Now if you do it fast inough then the animation goes silly and it wont load.
Why is that?
one more thing is it okay to use that script you gave me twice on the same page?
or will that screw things up