[英]Page redirect to next page
我在我的应用程序中使用map api。要选择标记,请使用名为“ Add marker
”的按钮和用于刷新Refresh map"
的按钮。
保存数据后,保存按钮将重定向到下一页。在我的情况下,“添加标记”, "Refresh map"
都在执行保存按钮工作,如果我按"Add 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>
refreshmarker.html
<button type="submit" title="Refresh map" class="map_buttons button_style">Refresh map</button>
addmarker.html
<button type="submit" title="Add marker" class="map_buttons button_style">Add marker</button>
需要对此问题进行澄清。
问题是因为两个按钮的类型都为submit
,当您单击其中任何一个按钮时,都会提交表单。 结果,页面被重定向为oto 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.