/    Sign up×
Community /Pin to ProfileBookmark

Help me please!

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

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieJun 20.2005 — No JavaScript is required to take you to the address, but once there some kind of server side script must execute to perform the search.

Solution to 1, however this will add a [FONT=Courier New]q=[/FONT] before the search term:

<!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>
Copy linkTweet thisAlerts:
@woNTarauthorJun 21.2005 — [B]BigMoosie[/B] thanks! But how can I do without q=?
Copy linkTweet thisAlerts:
@BigMoosieJun 21.2005 — What use would it be without the q= ? You can make it what ever you want. hello=, search=, but to do it without that will require javascript.

Or there is the possiblility of modifying the string once it reaches the server. What are server coding are you using?
Copy linkTweet thisAlerts:
@woNTarauthorJun 21.2005 — [B]BigMoosie[/B] look what I have:

<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 have a website and I want to put a search engine to it. This script I can put only in a page apart, but I want to put a link on main page, to be on main page a field text and a button, and clicking on button to get this page. This search engine is searching like this http://mypage.com/search.html?thewordIwriteintextfield, if this page is named search.html. Who can do what I want? please write me the code because I don't now nothing Javascript, just a little of html code (sorry for my English)
Copy linkTweet thisAlerts:
@BigMoosieJun 22.2005 — Since it is a JavaScipt search engine I guess the solution can be javaScript, but bear in mind that this is not a very adequate search, 10% of people wont be able to use it as they browse without javaScript enabled:

<i>
</i>&lt;FORM name="myForm"&gt;
&lt;INPUT name="terms" type="text"&gt;&lt;INPUT type="submit" value="Search"&gt;
&lt;/FORM&gt;
&lt;SCRIPT type="text/javascript"&gt;
&lt;!--
var subject=document.forms.myForm;
subject.onsubmit=function(){
window.location.href="http://www.apple.com/?"+subject.terms.value;
return false;
}
//--&gt;
&lt;/SCRIPT&gt;
Copy linkTweet thisAlerts:
@woNTarauthorJun 22.2005 — [B]BigMoosie[/B] what is the best solution to make a search engine? in Javascript or PHP?
Copy linkTweet thisAlerts:
@BigMoosieJun 22.2005 — PHP for sure. JavaScript has to send the data of every page to the user then search which is very bad. PHP will do this before it gets to the user so no matter what machine they are using it will work. If your site is large then you might need to use it in conjunction with a database as looking at all your pages on each search might use up a lot of resources and be slow. You would make it automatically update the database every time you modified a page.
Copy linkTweet thisAlerts:
@woNTarauthorJun 22.2005 — [B]BigMoosie[/B] thanks one more time. Do you have such a search engine in php? a small-made one?
Copy linkTweet thisAlerts:
@BigMoosieJun 23.2005 — No, shouldnt be too hard to search for.
Copy linkTweet thisAlerts:
@woNTarauthorJun 23.2005 — ok, thanks for all [B]BigMoosie[/B]
×

Success!

Help @woNTar 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.19,
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,
)...