日期:2014-05-17 浏览次数:20523 次
... <form action = "results.php" method="post"> Choose Search Type:<br /> <select name ="searchtype"> <option value="author">Author</option> <option value="title">Title</option> <option value="isbn">ISBN</option> </select> <br /> Enter Search Term:<br /> <input name="searchterm" type="text" size="40"> <br /> <input type="submit" name="submit" value="search" onClick="window.location='results.php'" /> </form> ...
... <?php $searchtype=$_POST['searchtype']; $searchterm=trim($_POST['searchterm']); if(!$searchtype || !$searchterm) { echo 'You have not entered search details. Please go back and try again.'; exit; } ...
<form action = "results.php" method="post"> Choose Search Type:<br /> <select name ="searchtype"> <option value="author">Author</option> <option value="title">Title</option> <option value="isbn">ISBN</option> </select> <br /> Enter Search Term:<br /> <input name="searchterm" type="text" size="40"> <br /> <input type="submit" name="submit" value="search" /> </form>
------解决方案--------------------
<form name="testForm" action = "results.php" method="post"> Choose Search Type:<br /> <select name ="searchtype"> <option value="author">Author</option> <option value="title">Title</option> <option value="isbn">ISBN</option> </select> <br /> Enter Search Term:<br /> <input name="searchterm" type="text" size="40"> <br /> <!-- html中的事件都是小写 --> <input type="submit" name="submit" value="search" onclick="subForm()" /> </form> <script> function subForm(){ document.testForm.action = "results.php"; document.testForm.submit(); } //如果使用location.href将直接跳转页面,除非后面加参数,那也是用get接收 </script>
------解决方案--------------------