在一页中,我有两种搜索形式:
<form class="search-panel" method="post" action="" onsubmit="return searchRedirect(this)">
<input type="test" name="searchFor" />
<div class="additional-search-button"></div>
<div id="additional-search-box">
<div class="as-cont">
Books<input type="radio" name="category" value="Books" checked="1" /><br/>
School<input type="radio" name="category" value="School" /><br/>
Music<input type="radio" name="category" value="Music" />
</div>
</div>
<input type="submit" name="search" />
</form>
<form class="search-panel" method="post" action="" onsubmit="return searchRedirect(this)">
<input type="test" name="searchFor" />
Games<input type="radio" name="category" value="Games" checked="1" />
<input type="submit" name="search" />
</form>
我的问题是,如果我在 searchRedirect 中单击搜索游戏,如果它们检查过,总是会提醒书籍、学校或音乐:
那是我的javascript函数:
function searchRedirect(form) {
alert($(form['category']+':checked').val());
if($(form['category']+':checked').val() == 'Форум')
window.location.href = '/forum/search.php?keywords='+form['searchFor'].value;
else {
window.location.href = '/Search/'+$(form['category']+':checked').val()+'/'+form['searchFor'].value;
}
return false;
}
如果我点击搜索游戏,我需要 - 只搜索游戏,如果点击搜索书籍、学校或音乐 - 只搜索它们。但是现在搜索游戏的表单总是使用第一个表单检查按钮。