日期:2014-05-16 浏览次数:20337 次
<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>
function search(){ window.location.href=document.getElementById('searchselect').value; }
------解决方案--------------------
<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>