我有以下表格:
<form name="frmSearch" id="frmSearch" action="search_results.html" method="get">
<table>
<tr>
<td><input type="text" id="txtQuery" placeholder="What are you hungry for ?" required="true"></td>
</tr>
<tr>
<td><input type="text" id="txtLocation" placeholder="Your location" required="true">
</tr>
<tr>
<td align="middle"><input type="submit" placeholder="Let's Eat!" ></td>
</tr>
</table>
</form>
当我点击“Let's Eat”按钮(提交按钮)时,启动的新页面的 URL 不包含两个输入字段中的值:
http://localhost:8000/search_results.html?
这是为什么?
最佳答案
您的输入
需要name
属性。
关于javascript - 在 HTML 表单上使用 GET 作为方法不会附加到 URL 中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37668838/