Java Script与PHP配合实现智能化的搜索界面

Java Script与PHP配合实现智能化的搜索界面

<?php
require("inc/conn.inc");//连接数据库
?>

<html>
<head>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<TITLE>深圳个体私营企业在线</TITLE>
<METAcontent="text/html;charset=gb2312"http-equiv=Content-Type>
</head>
<BODY>
<linkrel="stylesheet"href="inc/index.css"type="text/css">
<scriptlanguage="JavaScript">
<!--
functionleftcheck(theForm)
{
with(theForm){
if(s_type.value=="")
{
alert("非常抱歉!如果您希望执行搜索功能/n请先选择搜索类别!");
s_type.focus();
return(false);
}
if((sub_type.options[0].text=="无子项目/可选")&&((key.value=="")||(key.value=="请输入关键字")))
{
alert("抱歉!由于没有指定子项目,您必须输入有效的关键字!");
key.value="";
key.focus();
return(false);
}
if((key.value=="请输入关键字")||(key.value=="/可输入公司名"))
{
alert("抱歉!您输入了错误的关键字!");
key.value="";
key.focus();
return(false);
}
}
}
functionchgitem(sel_func)
{
varfunc=sel_func;
switch(func){
case"company":
search.key.value="/可输入公司名";
search.sub_type.options[0].text="/可继续选行业";
search.sub_type.options[0].value="";
<?
//取出公司分类的样本数据
$querytype="SELECT*FROMsampleWhereSample_Type='Company'";
$resultType=mysql_query($querytype);
$numRows=mysql_num_rows($resultType);
echo
'search.sub_type.options.length='.($numRows+1).';'.chr(13).chr(10);
for(
$i=0;$i<$numRows;$i++){
$rowType=mysql_fetch_array($resultType);
$d_value=$rowType["Sample_Value"];
if(
strlen($d_value)>12){
$d_value=substr($d_value,0,10)."..";
}
echo
'search.sub_type.options['.($i+1).'].text="'.$d_value.'";'.chr(13).chr(10);
echo
'search.sub_type.options['.($i+1).'].value="'.$rowType["Sample_ID"].'";'.chr(13).chr(10);
}
?>
break;
case"forum":
search.key.value="请输入关键字";
search.sub_type.options.length=1;
search.sub_type.options[0].text="无子项目/可选";
search.sub_type.options[0].value="";
break;
default:
search.key.value="请选搜索类别";
search.sub_type.options.length=1;
search.sub_type.options[0].text="暂无子项目/可选";
search.sub_type.options[0].value="";
}
}
//-->
</script>
<formname=searchaction="serach.php"method="post">
<p>站内搜索:</p>
<p><selectsize=1name=s_typeOnChange=chgitem(this.value)>
<option>选择搜索类别</option>
<optionvalue="company">会员企业搜索</option>
<optionvalue="forum">论坛搜索</option>
</select></p>
<p><selectsize=1name=sub_type>
<option>请先选择总类</option>
</select></p>
<p>输入搜索关键字<br>
<inputmaxlength=20size=12name=keyonClick="Javascript:this.value='';">
</p>
<inputtype="submit"name="iE4"Value="go">
</form>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值