我有一个带有3个输入和步骤按钮的html表单.
每当用户按下任何按钮,然后转到下一个html步骤.
我希望views.py在用户按任何按钮的任何时候逐步处理输入,而不是在最终提交中一起处理输入.
我尝试使用此代码在views.pydjango后端获取输入,但我没有得到任何东西views.py(如果我更改按钮类型button,submit然后我得到结果坚果刷新页面,我不能转到第2步)
if request.method == 'POST' and 'first_step' in request.POST:
print '1'
firstname= request.POST.get('firstname')
if request.method == 'POST' and 'second_step' in request.POST:
print '2'
lastname= request.POST.get('lastname')
if request.method == 'POST' and 'final_step' in request.POST:
print '3'
email= request.POST.get('email')
Run Code Online (Sandbox Code Playgroud)
这是我的HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Form wizard with circular tabs</title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</head> …Run Code Online (Sandbox Code Playgroud)