django弹出对话框_Django:popup弹出框简单应⽤实例效果:在p1.html页⾯点击,弹出p2的弹出框,填写数据,在 popup_response页⾯处理数据
1、url设置
urlpatterns = patterns(
url(r'^p1.html',views.p1),
url(r'^p2.html', views.p2),
)
2、视图函数:views.py
from django.shortcuts import render
def p1(request):
return render(request,"p1.html")
def p2(request):
django项目实例hod == "GET":
return render(request,"p2.html")
hod == "POST":
city =("city")
print(city)
return render(request,"popup_response.html",{"city":city})
3、前端页⾯及函数
p1.html
Title
P1页⾯
上海
北京
function popupfunc() {
window.open("/p2.html","popup_page","status=1,height:500,width:600,toolbar=0,resizeable=0")
}
{# alert("接收p2弹出框数据:"+data)#}
function p1_receive_func(data) {
var op = ateElement("option");
op.innerHTML = data;
op.setAttribute("selected","selected");
}
p2.html
Title
这是P2页⾯
{% csrf_token %}
popup_response.html
正在返回
(function () {
var name ="{{ city }}";
window.opener.p1_receive_func(name); window.close();
})()
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论