3 回答

TA貢獻1853條經驗 獲得超6個贊
如果您確實希望將請求方法保留為 GET,則可以將 an 應用于id您的form標簽;然后將 an 添加onclick="submitForm()"到您的input標簽(這也適用于img標簽或任何標簽)。然后我們將用一些簡單的 JavaScript 代碼定義我們的函數。希望我有幫助!
<form id="form" method="GET" action="/filtered">
<div class="slider-wrapper"><!-- innermost wrapper element -->
<input onclick="submitForm()" class="slide" type="image" style="width: 100%; height: 60vh;" name="category" value="Car Cleaning Products" alt="Car Cleaning Products" src="../public/css/img/paper-products-slideshow.JPG">
</div>
</form>
<script>
function submitForm() {
document.getElementById("form").submit();
}
</script>

TA貢獻1827條經驗 獲得超9個贊
只需將form方法更改為POST即可。
<form method="POST" action="/filtered">
<div class="slider-wrapper">
<!-- innermost wrapper element -->
<input class="slide" type="image" style="width: 100%; height: 60vh;" name="category" value="Car Cleaning Products" alt="Car Cleaning Products" src="../public/css/img/car-cleaning-slideshow.JPG">
<input class="slide" type="image" style="width: 100%; height: 60vh;" name="category" value="Car Cleaning Products" alt="Car Cleaning Products" src="../public/css/img/jan-supplies-slideshow.JPG">
<input class="slide" type="image" style="width: 100%; height: 60vh;" name="category" value="Car Cleaning Products" alt="Car Cleaning Products" src="../public/css/img/paper-products-slideshow.JPG">
</div>
</form>
添加回答
舉報