django弹出对话框_Django:popup弹出框简单应用实例

本文介绍如何在Django中实现弹出对话框功能。通过点击P1页面,弹出P2页面的对话框,用户输入数据后在popup_response页面处理。主要涉及URL配置、视图函数编写和前端页面交互。
摘要由CSDN通过智能技术生成

效果:在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):

if request.method == "GET":

return render(request,"p2.html")

elif request.method == "POST":

city =request.POST.get("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,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值