页面重定向到下一页

2024-04-19 14:07:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在我的应用程序中使用map api应用程序选择标记,按钮名为“Add marker”和“Refresh map"”用于刷新地图。你知道吗

保存数据后,“保存”按钮将重定向到下一步第页,共页在我的例子中,两个“addmarker”和"Refresh map"都在执行save buttons任务,如果我按"Add marker"而不是显示marker,页面将重定向到下一个第页。这个在使用</form>之后发生。请参阅我的模板

<form method="POST" action="/member/where/" >
{% csrf_token %}
<td colspan="2" class="incident-type" style="padding-left:25px">
  {% for location in locationList%}
  {% if location.parent_location_id == None %}
  <h1>{{location.title}}</h1>
  {% endif %}
{% endfor %}
<p>
<span class="map_buttons" >{% include "buttons/refreshmap.html" %}</span> <span class="map_buttons" style="margin-left:20px;">{% include "buttons/addmarker.html" %} </span>
</p>
<p id=ir-nextbtn>{% include "buttons/next.html" %}</a></form></p>

你知道吗刷新标记.html你知道吗

<button type="submit" title="Refresh map"  class="map_buttons button_style">Refresh map</button>

你知道吗添加标记.html你知道吗

<button type="submit" title="Add marker"  class="map_buttons button_style">Add marker</button>

这个问题需要澄清。你知道吗


Tags: 标记formaddmaptitlestylehtmltype
1条回答
网友
1楼 · 发布于 2024-04-19 14:07:18

问题是因为这两个按钮的类型都是submit,当您单击其中一个按钮时,表单就会被提交。结果,页面被重定向到表单的action,即/member/where/

试试看这是:- 保持刷新状态

  <button type="submit" title="Refresh map"  class="map_buttons button_style">Refresh map</button>

并添加

 <button onClick=somefuntion(this)' title="Add marker"  class="map_buttons button_style">Add   marker</button>

让一些函数来满足需要

<script>
function somefuntion(button){
    // your code
   document.forms[0].submit() // this will submit your form
 }
</script>

相关问题 更多 >