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>
添加回答
举报