排版 网站,南雄市建设局网站,网站建设优化服务平台,wordpress 展开折叠常用场景组合条件查询点击查询/刷新页面#xff0c;包括input输入框\复选框等在内的组件都可以通过前端设置value{{id}}#xff0c;后台发送的数据包括对应的字段#xff0c;从而实现刷新后保留上一次的值#xff0c;提高用户体验#xff0c;但是发现select不…常用场景组合条件查询点击查询/刷新页面包括input输入框\复选框等在内的组件都可以通过前端设置value{{id}}后台发送的数据包括对应的字段从而实现刷新后保留上一次的值提高用户体验但是发现select不能这么做它的value值是约定好并传给后台的后台可以传回来但无法直接显示。网上搜的资料五花八门自己用jquery实现了效果html代码段全国北京上海广州深圳杭州苏州南京成都重庆武汉js后台是django函数如下def search_handle(request):post request.POSTinput_contentpost.get(input_content).strip()input_cityidpost.get(input_cityid,0)# print(input_cityid)# print(input_content)city全国if input_cityid 0:city全国params (% input_content %)cursor connection.cursor()cursor.execute(SELECT * FROM event where eventTilte like %s ,params )else:if input_cityid 1:city北京elif input_cityid 2:city上海elif input_cityid 3:city广州elif input_cityid 4:city深圳elif input_cityid 5:city杭州elif input_cityid 6:city苏州elif input_cityid 7:city南京elif input_cityid 8:city成都elif input_cityid 9:city重庆elif input_cityid 10:city武汉params (% input_content %,% city %)cursor connection.cursor()cursor.execute(SELECT * FROM event where eventTilte like %s and eventAddress like %s ,params )event_list cursor.fetchall()cursor.close()content {event_list:event_list,input_content:input_content,input_cityid:input_cityid}return render(request,c_activity/search.html,content)另外还可以通过ajax来实现后面再总结吧。。