该程序是一段搜索程序,主要内容为:
<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程序关联的。

解决方案 »

  1.   

    Verify是不是用这个函数调用的脚本的
      

  2.   

    楼主查一下js代码,看看这个click事件是不是在别的地方重新定义了。
      

  3.   

    都没有Verify函数,你怎么去关联啊.
      

  4.   

    头部有一些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>
      

  5.   

    应该是 form那段代码 你贴出来 看看
      

  6.   

    没有Verify函数啊,楼主把代码全贴全吧
      

  7.   

    <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> 你查看一下这几个js文件!
      

  8.   

    应该在这几个js文件里 定义的Verify函数
      

  9.   

    应该在这几个js文件里 定义的Verify函数
      

  10.   

    <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>去这四个文件看看JS代码
      

  11.   

    <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> 
    我也觉得那个函数在几个JS文件里面。你找找看吧
      

  12.   

    <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>
      

  13.   

    to anlianganl :是不是这段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>
      

  14.   

    <button type="submit"  OnClick="Verify" />搜 索 </BUTTON>  //点击触发事件Verify
    </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; 
    //将查询的值 付给一个文本 //猜想是插入到数据库中的