表单传递数据 input name 相同的如何传递
1个回答
展开全部
i前端:nput_test.html
<!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><title>Search</title><script></script></head><body><div><p>{{ result }}</p></div><form action="" method="post">{% csrf_token %}<input type="text" name="key"><input type="text" name="key"><input type="submit" value="Search" ></form></body></html>
两个<input >标签name都是'key'
后台:Django views.py
def setting(request):if request.method == 'POST':result_list = request.POST.getlist('key', '')result = str(result_list)return render_to_response('input_test.html', locals(), context_instance=RequestContext(request))else:return render_to_response('input_test.html', locals(), context_instance=RequestContext(request))
<!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><title>Search</title><script></script></head><body><div><p>{{ result }}</p></div><form action="" method="post">{% csrf_token %}<input type="text" name="key"><input type="text" name="key"><input type="submit" value="Search" ></form></body></html>
两个<input >标签name都是'key'
后台:Django views.py
def setting(request):if request.method == 'POST':result_list = request.POST.getlist('key', '')result = str(result_list)return render_to_response('input_test.html', locals(), context_instance=RequestContext(request))else:return render_to_response('input_test.html', locals(), context_instance=RequestContext(request))
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询