Hi
I am developing a business search site. At the moment users can type in a category into a text field such as 'Architects' and they will be directed to a architects.html page. What I need is for the users to type in a category into one textfield and a location into another textfield ie( 'Architects' & 'Canterbury,
Here is the code i have so far
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
// holds list of search words as well as page to be redirected
var context = "mechanics.html ! Mechanics | plumber.html ! Plumbers | architects.html ! architects";
// populates the data into an array
var list = contextToArray(context);
// function that parses a string and returns a named array
function contextToArray(value)
{
var listArray = [];
var rows = value.split("|");
for (var i=0;i<rows.length;i++)
{
var fields = rows[i].split("!");
var page = trim(fields[0]);
var text = trim(fields[1]).toLowerCas
e();
listArray[text] = page;
}
return listArray;
}
// function to trim leading and trailing spaces
function trim(text)
{
return text.replace(/(^\s*)|(\s*$
)/g, "");
}
function searchResults()
{
// get the text, trim it and lower all the cases
var text = trim(document.forms[0]["cr
iteria"].v
alue).toLo
werCase();
// search from the array now
if (! list[text])
{
// show alert when no results were found
alert("No Resulting Page Found");
}
else
{
window.location.href = list[text];
}
}
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
<!--
<!--
<!--
<!--
<!--
<!--
<!--
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(p
arseInt(ap
pVersion)=
=4)) {
document.MM_pgW=innerWidth
; document.MM_pgH=innerHeigh
t; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_p
gW || innerHeight!=document.MM_p
gH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<div align="center">
<div align="left">
<table width="883" height="588" border="0" cellpadding="0">
<!--DWLayoutTable-->
<tr>
<td width="800" height="94" valign="top"><img src="file:///C|/asmsearch2
/asmlogo.j
pg" width="800" height="80"></td>
<td width="77"></td>
</tr>
<tr>
<td height="79" colspan="2" valign="top" bgcolor="#C5D4E9"><form name="myform" method="post" onsubmit= "searchResults(); return false;" >
<div align="left">
<p><br>
<font color="#4F558F" size="2" face="Verdana, Arial, Helvetica, sans-serif"> <s
trong>Sear
ch
For</strong></font>:
<input name="criteria" type="text" size="35" >
<font color="#4F558F" size="2" face="Verdana, Arial, Helvetica, sans-serif"> &n
bsp;
<strong>Lo
cated
in</strong></font><strong>
:</strong>
<input type="text" name="textfield">
<input type="submit" value="search" onclick ="searchResults();">
&n
bsp;
<br>
<br>
<font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif"><strong>
&nbs
p;Home
| Useful info | Advertise with us | Web Design </strong></font></p>
</div>
</form></td>
</tr>
<tr>
<td height="407" valign="top"> &
nbsp; 
;<br>
&n
bsp;
&nbs
p; &n
bsp;
&nbs
p; &n
bsp;
&nbs
p; </td>
<td></td>
</tr>
</table>
</div>
</div>
<center>
</center>
<p>
<center>
<p align="center"><font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif"><strong>
</st
rong></fon
t></p>
</center>
<p align="center">
<!-- Script Size: 3.16 KB -->
<div align="left"></div>
</body>
</html>