在 html 中让一个按钮触发另一个按钮

making one button trigger another in html

我有一个让用户下载文件的按钮,我有一个需要在用户单击下载按钮时 POSTed 的表单。

<a class="down" href="{{x.image.url}}" download="none">
     <button>get</button>
</a>
<form action="/image_info/" method="POST" id='image_form'>
    {% csrf_token %}
    <input name='info_button' type="hidden" value="{{x.id}}>
    <button class="imginfo" type="submit">info</button>
</form>

因此,在此我希望提交 image_form 并在 down 按钮为 pressed.Basically 时下载图像 imginfo 提交按钮应为按下下载按钮时按下。谢谢!

像这样给下载按钮一个onclick事件

    <a class="down" href="{{x.image.url}}" download="none"><button onclick="myfunc()">get</button></a>

现在定义一个 js 函数 myfunc() 以在单击下载按钮时提交表单

          <script type="text/javascript">
          function myfunc()
          {
            document.getElementById("dform").submit();
          }
        </script>