日期:2014-05-16  浏览次数:20328 次

对二个页面搜索怎么写?
HTML code
<form id="form1"name="form1"method="post"action="">

<select id="searchselect">
<option value="aaa/search.php">aaa</option>
<option value="bbb/search.php">bbb</option>
</select>
                        
<input id="keyword_s" type="text" name="keyword" />

<input type="submit" name="submit" value="搜索" />

</form>

<script type="text/javascript">
<!--
function cksearch(){
    if (document.getElementById("keyword_s").value=='')
    {
        alert('关键字不能为空!');
        return false;
    }
}
//-->
</script>


我想当我在下拉框选择aaa时,点搜索是对aaa/search.php文件进行搜索,

当我在下拉框选择bbb时,点搜索是对bbb/search.php文件进行搜索,我的文件应该怎么写?





------解决方案--------------------
JScript code

function search(){
   window.location.href=document.getElementById('searchselect').value;
}

------解决方案--------------------
HTML code

<form id="form1" name="form1" method="post" action="" onsubmit="getSubmit()">
<select id="searchselect">
<option value="aaa/search.php">aaa</option>
<option value="bbb/search.php">bbb</option>
</select>
                        
<input id="keyword_s" type="text" name="keyword" />

<input type="submit" name="submit" value="搜索" />

</form>

<script type="text/javascript">
<!--
function cksearch()
{
    if(document.getElementById("keyword_s").value == "")
    {
        alert("关键字不能为空!");
        return false;
    }
}
function getSubmit()
{
    document.form1.action = document.getElementById("searchSelect").value;
    document.form1.submit();
}
//-->
</script>