搜索表单不起作用"onclick"



我在搜索框上遇到了麻烦。它只在我按回车键时起作用,当我点击"搜索"按钮时不起作用。

代码如下:

(php)
<form id="search" action="search.php" method="GET">
                                <input type="text" name="s">  
    <a class="submit" onClick="document.getElementById('form').submit()"></a>

(js)
$(function(){
var s=location.search.replace(/^?.*s=([^&]+)/,'$1')
    ,form=$('#search')
    ,form=$('#search-form')
    ,input=$('input[type=text]',form)
    ,results=$('#search-results').height(0)
    ,src='search/results.php'
    ,ifr=$('<iframe width="100%" height="100%" frameborder="0" marginheight="0" marginwidth="0" allowTransparency="true"></iframe>')
if(results.length)      
    ifr     
        .attr({
            src:src+'?s='+s
        })
        .appendTo(results)
    ,input
        .val(decodeURI(s))
window._resize=function(h){     
    results
        .height(h)
}

})

提前感谢您的帮助!div;)

我认为document.getElementById('form')应该是:

document.getElementById('search')

这是我立刻想到的

最新更新