2013-03-16 44 views
0

我遇到搜索框有问题。它只有当我点击 “进入”,而不是当我点击 “搜索” 按钮工程..搜索表单不起作用“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) 
} 

})

在此先感谢您的帮助! ;)

+0

你的js控制台告诉你什么? ctrl + shift + j – tay10r 2013-03-16 19:46:07

+0

@TaylorFlores ctrl-shift-j仅适用于Firefox。在大多数浏览器中,它是F12。 – Markasoftware 2013-03-16 19:49:19

+0

@RicardoFilipeJorge我看到你是新来的!一件小事:为了获得更多关注,你不喜欢你所有的问题。 – Markasoftware 2013-03-16 19:51:19

回答

1

我觉得document.getElementById('form')应该是:

document.getElementById('search')

这就是立即在我弹出。

+0

你应该可以肯定 – Sedz 2013-03-16 19:48:48

+0

嗯..没有TypeError:不能调用方法'submit'null .. – 2013-03-16 19:52:16

+0

你可以看到网站http://www.dasquintas.com/dasquintas – 2013-03-16 19:53:05