HTML页面:
<form method="get" action="#">
<table style="width:100%">
<tr>
<th>Slno</th>
<th>Name</th>
<th>Attendance</th>
</tr>
<tr>
<td>1</td>
<td>Abijith</td>
<td>{{ p }}
<input type="submit" value="present" name="add"/>
<input type="submit" value="absent" name="add1"/>
{{ a }}
</td>
</tr>
</table>
Views.py:
p = 1; a = 1;
def Ist_std(request):
global p,a
my_dictionary = {
"p" : p, "a" : a
}
if request.GET.get('add'):
p = p+1
my_dictionary = {
"p" : p,
}
if request.GET.get('add1'):
a = a+1
my_dictionary = {
"a" : a,
}
return render(request, "blog/Ist_std.html", my_dictionary)
我想在屏幕上显示该值。但现在我只有在点击按钮时才会看到{{ p }}
和{{ a }}
的值。如何在不点击的情况下显示值?