Home » Web-services » Enhancing a Search Form with Random Quotes

Our goal is to make little but useful enhancement to search form of a website. The advance is obvious —it helps to point a visitor to our most interesting pages or to give him a clue about main topics of the web resource.

The keywords for the search results will change with every page refresh. You could see the working example on the top of the right column on this page.

The php and html source code is as follows:

01 
02 
03 
04 
05 
06 
07 
08 
09 
05 
06 
07 
08 
09 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34
 <?
   $bCount= 1; 

   $bCode[$bCount] = "pilser"; 
   $bCount++;
   $bCode[$bCount] = "ideas"; 
   $bCount++;
   $bCode[$bCount] = "consulting"; 
   $bCount++;


$bAdTotal = $bCount - 1; 
if($bAdTotal>1) 
{
   mt_srand((double)microtime() * 1234567); 
   $bPicked = mt_rand(1, $bAdTotal); 
}
else
{
   $bPicked = 1; 
}
$bAd = $bCode[$bPicked]; 
?>


<html>
<head></head>
<body>
<form name="web" method="get" action="">
<input type="hidden" name="a" value="search">                    
<input type="text" style="COLOR: #6d6d6d" 
onfocus="if(this.value=='search...')this.value=''" 
maxLength=255 value="search..." name="q" size="15" />
<input style="type=submit value="Go"><br />
Try <SPAN style="CURSOR: pointer; TEXT-DECORATION: underline" 
onclick="javascript:document.forms['web'].q.value='$bAd'; 
return false;">$bAd</SPAN>
</form>
</body></html>

You could add as many random keywords as you wish —just add them to bCount. Be accurate with the names of the web form elements, othewise your javascript will not work.


Business Guide

Website Types
Promotion and Revenue
Online Payment

Business Services

Affiliate Programs
Commerce Services
Domains and Hosting
Link Directories
Link Marketing
PCM Programs
PPC Programs
Scripts Directories

Useful Services

Web Services
Ideas
System Thinking

Subscription

Latest Pilser.com News:

Powered by our Feed

Search

 
Example: Ideal Gift

eXTReMe Tracker