我對JavaScript不太熟悉,我需要幫助。我想使用JavaScript提交表單。下面是一個代碼:提交表單時出現Javascript問題
<script type="text/javascript">
function submitform()
{
document.forms["myform"].submit();
}
</script>
<form name="myform" action="index.php?id=search">
<div class="searchleft"><?php echo $search['search']; ?>:</div>
<div class="searchbox"><input type="text" name="query" id="searchbox"></div>
<div class="searchbtn"><input name="search" onClick="submitform()" type="button"></div>
</form>
我想按下一個按鈕,看起來像後鏈接:http://127.0.0.1/index.php?id=search&query=blabla
,但不幸的是它看起來:http://127.0.0.1/index.php?query=blabla
我有什麼改變,使它看起來像我想要的嗎?
<form name="myform" action="index.php?id=search">
<input type="hidden" name="id" value="search" />
<div class="searchleft"><?php echo $search['search']; ?>:</div>
<div class="searchbox"><input type="text" name="query" id="searchbox"></div>
<div class="searchbtn"><input name="search" onClick="submitform()" type="button"></div>
</form>
非常感謝! – Lina
打我一分鐘:) – macou