Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在图像上提交表单单击html_Javascript_Html_Slideshow - Fatal编程技术网

Javascript 在图像上提交表单单击html

Javascript 在图像上提交表单单击html,javascript,html,slideshow,Javascript,Html,Slideshow,我试图在点击幻灯片图像时提交我的表单。我创建了一个表单,并使用type=“image”输入值,但今天意识到有些浏览器无法处理中的值输入。最好的方法是什么 <form method="GET" action="/filtered"> <div class="slider-wrapper"><!-- innermost wrapper element -->

我试图在点击幻灯片图像时提交我的表单。我创建了一个表单,并使用
type=“image”
输入值,但今天意识到有些浏览器无法处理
中的值输入。最好的方法是什么

<form method="GET" 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>

使用
method=“post”
get是获取数据而不是发送数据


我相信这会起作用

如果您确实希望保持请求方法为GET,您可以将
id
应用于
表单
标记;然后将
onclick=“submitForm()”
添加到
input
标记中(这也适用于
img
标记或任何其他标记)。然后,我们将在一些简单的javascript代码中定义我们的函数。希望我能帮忙



函数submitForm(){
document.getElementById(“表单”).submit();
}

只需将
表单
方法更改为
POST
即可



您可以在图像上方添加
显示:无
。不幸的是,我确实这样做了,不幸的是,仍然无法工作。不过,我确实很喜欢这种方法,因为我编写后端代码的方式无法将表单作为帖子提交。也许可以尝试删除浏览器历史记录/缓存或使用“匿名”选项卡。如果不是这样,请尝试使用其他浏览器。我知道这段代码确实使用了正确的行为,所以听起来像是本地问题。我也试过了,非常奇怪,不知道为什么它不起作用。