Menu
1.I need to make a text field and a button, and clicking on button to get http//:mypage.com/search?thewordIwriteintextfield.
2.And how I can make a search engine?
at least tell me how to make the 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML lang="en">
<HEAD>
<TITLE>HTML</title>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
<FORM action="http://www.google.com/search" method="GET">
<DIV>
<INPUT type="text" name="q">
<INPUT type="submit" value="Search">
</DIV>
</FORM>
</BODY>
</HTML>
<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-x.com
1000s of free ready to use scripts, tutorials, forums.
Author: JS-Examples -http://www.js-examples.com/
-->
</head>
<body>
<script language="JavaScript">
<!--
var LOC = 0;
var TITLE = 1;
var KEYWORDS = 2;
var DESCRIPTION = 3;
var database = new Array();
function addEntry(_l,_t,_k,_d) {
var _next = database.length?database.length:0;
database[_next] = new Array();
database[_next][LOC]=_l;
database[_next][TITLE]=_t;
database[_next][KEYWORDS]=_k;
database[_next][DESCRIPTION]=_d;
}
addEntry("your_1_page.htm","Your First Page Title", "keywords for first file go here separated by spaces", "First page description here!");
addEntry("your_2_page.htm","Your Second Page Title","keywords for second file go here separated by spaces","Second page description here!");
addEntry("your_3_page.htm","Your Third Page Title", "keywords for third file go here separated by spaces", "Third page description here!");
addEntry("your_4_page.htm","Your Fourth Page Title","keywords for Fourth file go here separated by spaces","Fourth page description here!");
var menu = new Array();
function addMenu(_i) {
//alert(_i);
var _next = menu.length?menu.length:0;
menu[_next] = new Array();
menu[_next][LOC]=database[_i][LOC];
menu[_next][TITLE]=database[_i][TITLE];
menu[_next][KEYWORDS]=database[_i][KEYWORDS];
menu[_next][DESCRIPTION]=database[_i][DESCRIPTION];
}
// this function takes these arguments
// 1> pattern to search for - deliminated by spaces.
// 2> true for OR
// 3> true for AND
// 4> true for EXACT
// return value is the index found or -1 if none found
function findThis(_searchfor,_or,_and,_exact) {
var S = _searchfor.split(" ");
for(var i=0;i<database.length;i++) {
if(_or) {
for (var j=0;j<S.length;j++) {
if (database[i][KEYWORDS].indexOf(S[j]) != -1 ||
database[i][DESCRIPTION].indexOf(S[j]) != -1 ||
database[i][TITLE].indexOf(S[j]) != -1 ||
database[i][LOC].indexOf(S[j]) != -1) {
addMenu(i);
}
}
} else if(_and) {
// AND
var count=0;
for (var j=0;j<S.length;j++) {
if (database[i][KEYWORDS].indexOf(S[j]) != -1 ||
database[i][DESCRIPTION].indexOf(S[j]) != -1 ||
database[i][TITLE].indexOf(S[j]) != -1 ||
database[i][LOC].indexOf(S[j]) != -1) {
count++;
}
}
//alert(count+"n"+S.length);
if (count==S.length) {
addMenu (i);
}
} else if (_exact) {
//alert("["+_searchfor+"]n["+database[i][DESCRIPTION]+"]")
if (database[i][KEYWORDS].indexOf(_searchfor) != -1 ||
database[i][DESCRIPTION].indexOf(_searchfor) != -1 ||
database[i][TITLE].indexOf(_searchfor) != -1 ||
database[i][LOC].indexOf(_searchfor) != -1) {
addMenu(i);
}
}
}
return (-1);
}
// this function ENTRY
// is called when the new search is requested.
function entry() {
if ((document.entryform.keyword.value.length == 0) || (document.entryform.keyword.value == " ")) {
alert("First you must enter a keyword to search for.");
return false;
}
and_search = (document.entryform.and_or.selectedIndex == 0?"and":"or");
if (document.entryform.and_or.selectedIndex == 2)
and_search = "exact";
location.href = location.pathname + "?"+ escape(document.entryform.keyword.value) + (and_search != "or"?"&"+and_search:"");
return false;
}
var string="";
var and_search="";
function parseParms() {
var _l1 = document.location.toString().split("?");
var _l2 = "";
var _l3 = "";
if (_l1.length>=1)
_l2 = _l1[1];
if (_l2 && _l2.length>0) {
if (_l2.indexOf("&") != -1) {
_l3 = _l2.split("&")[1];
_l2 = _l2.split("&")[0];
}
}
string = unescape(_l2 || "");
and_search= unescape(_l3 || "or");
}
parseParms();
if (string && string != "") findThis(string,and_search=="or",and_search=="and",and_search=="exact");
var _a = '';
_a += '<form name="entryform" onSubmit="return entry()">';
_a += '<b>Search for:</b><br>';
_a += '<input type="text" size=20 name="keyword" value="'+string+'"> ';
_a += '<input type="button" value="Search" onClick="entry()"><br>';
_a += '<select name="and_or" size=1>';
_a += '<option'+(and_search=="and"?" selected":"")+'>find all words (AND)';
_a += '<option'+(and_search=="or"?" selected":"")+'>find any word (OR)';
_a += '<option'+(and_search=="exact"?" selected":"")+'>exact match';
_a += '</select>';
_a += '</form><br>';
document.write(_a);
if (location.search.length > 1)
document.write('<b>Results:</b><br><br>n');
for (n=0; n<menu.length; n++) {
var _a = '';
_a += '<b><a href="'+menu[n][LOC]+'">'+menu[n][TITLE]+'</a></b><BR>';
_a += menu[n][DESCRIPTION]+'<br>';
_a += 'Keywords: '+menu[n][KEYWORDS]+'<br><br>';
document.write(_a);
}
if ((menu.length == 0) && (location.search.length > 1))
document.write('Keyword "'+string+'" not found!n');
// -->
</script>
<BR><center><a href='http://www.js-x.com'>JS-X.com</a></center>
</body>
</html>[/QUOTE]
<i>
</i><FORM name="myForm">
<INPUT name="terms" type="text"><INPUT type="submit" value="Search">
</FORM>
<SCRIPT type="text/javascript">
<!--
var subject=document.forms.myForm;
subject.onsubmit=function(){
window.location.href="http://www.apple.com/?"+subject.terms.value;
return false;
}
//-->
</SCRIPT>
0.1.9 — BETA 5.19