该程序是一段搜索程序,主要内容为:
<button type="submit" OnClick="Verify" />搜 索</BUTTON>
</FORM> <script language="javascript">
function changeClass(str){
if(str=="product"){
document.topsearch.action='Productlist.aspx';
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="shop"){
document.topsearch.action='shop_search.aspx'
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="nick"){
document.topsearch.action='shop_search.aspx'
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="info"){
document.topsearch.action='News/search.aspx'
document.getElementById("proclass").style.display="none";
document.getElementById("newclass").style.display="";
}
}
function checkkeyword(){
if(document.topsearch.keyword.value==""){
alert("请输入搜索关键字");
document.topsearch.keyword.focus();
return false;
}
document.topsearch.SearchText.value=document.topsearch.keyword.value;
}
</SCRIPT>
我不明白的是<button type="submit" OnClick="Verify" />搜 索</BUTTON>这段程序如何跟下面的javascript程序关联的。
<button type="submit" OnClick="Verify" />搜 索</BUTTON>
</FORM> <script language="javascript">
function changeClass(str){
if(str=="product"){
document.topsearch.action='Productlist.aspx';
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="shop"){
document.topsearch.action='shop_search.aspx'
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="nick"){
document.topsearch.action='shop_search.aspx'
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="info"){
document.topsearch.action='News/search.aspx'
document.getElementById("proclass").style.display="none";
document.getElementById("newclass").style.display="";
}
}
function checkkeyword(){
if(document.topsearch.keyword.value==""){
alert("请输入搜索关键字");
document.topsearch.keyword.focus();
return false;
}
document.topsearch.SearchText.value=document.topsearch.keyword.value;
}
</SCRIPT>
我不明白的是<button type="submit" OnClick="Verify" />搜 索</BUTTON>这段程序如何跟下面的javascript程序关联的。
<HEAD>
<TITLE></TITLE>
<META http-equiv=keywords content= />
<meta name="description" content />
<link rel="shortcut icon" href="http://localhost/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="http://localhost/Skin/skin5/CSS/v2.0.css" type="text/css">
<link rel="stylesheet" href="http://localhost/Skin/skin5/CSS/layout.css" type="text/css">
<link rel="stylesheet" href="http://localhost/Skin/skin5/CSS/component.css" type="text/css">
<link rel="stylesheet" href="http://localhost/Skin/skin5/CSS/frontpage_v2.css" type="text/css">
<SCRIPT src="http://localhost/Skin/skin5/JS/yui-utilities.js" type=text/javascript></SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/tbra.js" type=text/javascript></SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/common.js" type=text/javascript></SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/top_new.js" type=text/javascript></SCRIPT>
</HEAD>
<SCRIPT src="http://localhost/Skin/skin5/JS/tbra.js" type=text/javascript> </SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/common.js" type=text/javascript> </SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/top_new.js" type=text/javascript> </SCRIPT> 你查看一下这几个js文件!
<SCRIPT src="http://localhost/Skin/skin5/JS/tbra.js" type=text/javascript> </SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/common.js" type=text/javascript> </SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/top_new.js" type=text/javascript> </SCRIPT>去这四个文件看看JS代码
<SCRIPT src="http://localhost/Skin/skin5/JS/tbra.js" type=text/javascript> </SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/common.js" type=text/javascript> </SCRIPT>
<SCRIPT src="http://localhost/Skin/skin5/JS/top_new.js" type=text/javascript> </SCRIPT>
我也觉得那个函数在几个JS文件里面。你找找看吧
<SELECT id=keywordtype onchange=changeClass(this.value) name=keywordtype>
<OPTION value=product selected>搜索商品</OPTION>
<OPTION value=shop>搜索店铺</OPTION>
<OPTION value=nick>搜索掌柜</OPTION>
<OPTION value=info>搜索资讯</OPTION>
</SELECT>
<input type="hidden" value="0" name=SearchKind>
<input type="hidden" value="" name=SearchText>
<INPUT class=findInto id=keyword name=keyword>
<span id=proclass></span>
<button type="submit" OnClick="Verify" />搜 索</BUTTON>
<A href="http://localhost/HighlevelSearch.aspx" target=_top>[ 高级搜索 ]</A>
<A href="/HELP"
target=_blank>[ 使用帮助 ]</A>
</FORM>
<form name=topsearch action="Productlist.aspx" onSubmit="return checkkeyword()" method="method" style="margin:0px">
<SELECT id=keywordtype onchange=changeClass(this.value) name=keywordtype>
<OPTION value=product selected>搜索商品 </OPTION>
<OPTION value=shop>搜索店铺 </OPTION>
<OPTION value=nick>搜索掌柜 </OPTION>
<OPTION value=info>搜索资讯 </OPTION>
</SELECT>
<input type="hidden" value="0" name=SearchKind>
<input type="hidden" value="" name=SearchText>
<INPUT class=findInto id=keyword name=keyword>
<span id=proclass> </span>
<button type="submit" OnClick="Verify" />搜 索 </BUTTON>
<A href="http://localhost/HighlevelSearch.aspx" target=_top>[ 高级搜索 ] </A>
<A href="/HELP"
target=_blank>[ 使用帮助 ] </A>
</FORM>
</FORM> <script language="javascript">
function changeClass(str){ //定义方法changeClass 要一个参数 str
if(str=="product"){ //如果str 与 “product” 相等
document.topsearch.action='Productlist.aspx'; //执行代码
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="shop"){ //如果str 与 “shop” 相等
document.topsearch.action='shop_search.aspx' //执行代码
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="nick"){ //如果str 与 “nick” 相等
document.topsearch.action='shop_search.aspx' //执行代码
document.getElementById("proclass").style.display="";
document.getElementById("newclass").style.display="none";
}else if (str=="info"){
document.topsearch.action='News/search.aspx'
document.getElementById("proclass").style.display="none";
document.getElementById("newclass").style.display="";
}
}
function checkkeyword(){
if(document.topsearch.keyword.value==""){ //document.topsearch.keyword.value 应该是取的文本值
alert("请输入搜索关键字");
document.topsearch.keyword.focus(); //提示后得到焦点 返回false 不执行
return false;
}
document.topsearch.SearchText.value=document.topsearch.keyword.value;
//将查询的值 付给一个文本 //猜想是插入到数据库中的
}