@Johnwm
oh nah I wasn't after javascript codes
I have a website that needs 'a' search engine
one solution was javascript...
that I can do but i was wondering if there were another way to solove this problem.
------------code-----------------
well here it is, its not perfect or CLEAN but it works (to an extent)
just copy it into a file ending with .htm
<html>
<title></title>
<head>
<script>
var Indexed_Webpage = new Array();
Index=0; Indexed_Webpage[Index]=new Array(0, "Cat_Webpage", "all about cats", " There are dozens of breeds of cat, some hairless or tailless as a result of mutations, and they exist in a variety of different colors. They are skilled predators and have been known to hunt over one thousand different species for food. They are also intelligent animals, and some can be trained or learn by themselves to manipulate simple mechanisms such as lever-handled doors and flush toilets ");
Index++; Indexed_Webpage[Index]=new Array(0, "Cat2", "Cat relation", " Much like some other domesticated animals (such as the horse), cats may also still live effectively in the wild as a feral cat. Contrary to the popular conception of the cat as a solitary animal, cats often form small colonies in the wild. ");
</script>
<script>
function Set_Document_innerHTML(ID_Name, innerHTML){
document.getElementById(ID_Name).innerHTML = unescape(innerHTML);
};
</script>
<base target="Main">
</head>
<body>
<table dir="ltr" cellSpacing="0" cellPadding="0" width="100%" border="0" id="table1">
<tr>
<td vAlign="top" align="center"><p>You may search our
web site for all
documents containing matching words or patterns.</p>
<p>try cat<br>
then skilled<br>
than cat skilled<br>
then c<br>
then apple</p>
<form id="Search_Form" name="Search_Form" method=get action="javascript:void(0)" onsubmit="Run_Search(document.Search_Form.Search_Form_Text.value)">
<p>
<input id="Search_Form_Text" name="Search_Form_Text" type="text" size="20">
<input type="submit" value="Submit" name="B4">
<input type="reset" value="Reset" name="B2"></p>
</form>
<div id="Search_Display">
</div>
</td>
</tr>
</table>
</body>
</html>
<script>
var Show_Size = 150;
var Page_ID = 0;
var Found_Color = "#0000FF"
var Found = "";
var Display = "";
var Content = "";
var Temp_Content = "";
var Heading_Frag = "";
var Content_Frag = "";
var Global_Temp;
var zxc = "";
function Run_Search(Var1)
{
Heading_Frag = "";
Content_Frag = "";
Found = "";
for(For_Index = 0; For_Index < Indexed_Webpage.length ; For_Index++){
Indexed_Webpage[For_Index][0] = 0;
}
Temp2 = Var1;
Global_Temp = Temp2.toLowerCase().split(" ");
For_Index = 0;
For_Index1 = 0;
Display = "<table border=\"0\" width=\"90%\"><tr><td>";
for(For_Index1 = 0; For_Index1 < Global_Temp.length ; For_Index1++){
for(For_Index = 0; For_Index < Indexed_Webpage.length ; For_Index++){
if(Indexed_Webpage[For_Index][0] < 1){
if(Search(For_Index, Global_Temp[For_Index1], 3)!= "Not Found"){
Indexed_Webpage[For_Index][0] = 1;
Content_Frag += Search(For_Index, Global_Temp[For_Index1], 3) + " ~qwert~ ";
Heading_Frag += "<p><a href=\"" + Indexed_Webpage[For_Index][1] + "\">" + Indexed_Webpage[For_Index][2] + "</a></p><p> ~qwert~ ";
//Found += "<p><a href=\"" + Indexed_Webpage[For_Index][1] + "\">" + Indexed_Webpage[For_Index][2] + "</a></p><p>" + Search(For_Index, Temp[For_Index1], 3) + "<br><hr></p>";
}
}
}
}
if(Heading_Frag != ""){
Color_Search();
Format_Length = 30;
for(For_Index9 = 0; For_Index9 < Global_Temp.length ; For_Index9++){
For_Index1=0;
while(For_Index1 < Content_Frag.length){
Found_Index = Content_Frag.toLowerCase().indexOf(" "+Global_Temp[For_Index9], For_Index1);
if(Found_Index > -1){
Found_Index_End = Content_Frag.indexOf(" ",Found_Index+1)
Content_Frag = Content_Frag.substring(0, Found_Index) + "<font color=\"" + Found_Color + "\">"
+ Content_Frag.substring(Found_Index, Found_Index_End) + "</font>"
+ Content_Frag.substring(Found_Index_End, Content_Frag.length);
For_Index1 = Found_Index_End+Format_Length;
} else{
For_Index1 = Content_Frag.length+1;
}
}
}
Head = Heading_Frag.split(" ~qwert~ ");
Body = Content_Frag.split(" ~qwert~ ");
for(For_Index = 0; For_Index < Head.length-1 ; For_Index++){
Display += Head[For_Index] + Body[For_Index] + "<br><hr></p>";
}
}
Display += "</td></tr></table>";
//zxc += Global_Temp[For_Index1];
Set_Document_innerHTML("Search_Display", Display);
//document.write(Display);
//document.write(zxc);
}
function Search(Var1, Var2, Var3)
{
Temp_Content = "Not Found";
Content = Indexed_Webpage[Var1][Var3].toString();
Reg_Exp = new RegExp(" "+Var2, "gi");
Index_Word = Content.search(Reg_Exp);
Index = Index_Word;
if(Index > -1){
if(Index-40 < 0){
Index = 0;
if(Index+Show_Size > Content.length){
Index_Last = Content.length;
} else{
Index_Last = Index+Show_Size
Index_Last = Content.indexOf(" ",Index_Last)
}
} else{
Index = Index-40
Index = Content.indexOf(" ",Index)
if(Index+Show_Size > Content.length){
Index_Last = Content.length;
} else{
Index_Last = Index+Show_Size
Index_Last = Content.indexOf(" ",Index_Last)
}
}
Index_Word_End = Content.indexOf(" ", Index_Word+1)
Temp_Content = Content.substring(Index, Index_Last)
}
return Temp_Content;
}
function Color_Search(){
}
</script>
------- end code --------
sorry about the mess everyone
and dont worry about the mess I know how to fix it up and I will do it later