By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Re: To add search in my page

P: n/a
On Sep 4, 11:01*pm, Betikci Boris <pard...@gmail.comwrote:
On Sep 4, 3:21*pm, lak <lakindi...@gmail.comwrote:
I want to search within my page. How can I do that. When I searched in
the net, it tells to use the google search. But I want to do for my
web page. I am using intra-net system.

If i unterstood correctly, you do not have too much content right.
ex. if *you do not have much than 1500 - 2000 pages, you can simple
use javascript for search.

use arrays to store your data, which will be used, available for
search process;

Ex. var data = new Array();

data[content] = new Array();

data[content][0] = ["x.html","keyword","keyword1","keyword2" ...
"keywordn"];
__________________________________________________ ______________________________
<script language="javascript">
// Author: Barış ÇUHADAR, Licence: GPL..
var c = new String(window.location); //http://foo.com/x.php?q=keyword
var s = c.split("="); // gets the keyword after "="
var flag = 0;

if(s[1])
{
* * s[1]=decodeURI(s[1]);

* * for(var i = 0; i < 3; i++)
* * {
* * * * for(var j = 0; j < site_data["content"][i]["keywords"].length;
j++)
* * * * * * if(site_data["content"][i]["keywords"][j].match(s[1]))
* * * * * * {
* * * * * * * * document.write("<a href="+site_data["content"][i][0]
[0]+">"+site_data["content"][i][0][1]+"</a>");
* * * * * * * * document.write("<br>");
* * * * * * * * document.write(site_data["content"][i][0][2]);
* * * * * * * * document.write("<br>");
* * * * * * * * document.write("<br>");
* * * * * * * * flag = 1;
* * * * * * }
* * * * * * else if(flag !=1) { flag = 2;}
* * }
* * if(flag == 2)
* * {
* * * * document.write("nothing found");
* * }}

else if(flag == 0) { document.write("enter something to search");}

</script>
__________________________________________________ _____________________

when you search within keywords by a loop, you can simply built a
simple js search engine skeleton.
I use this approach in Interactive-CD's + SQLite3 + PHP
Sep 4 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.