In this, only second button is working. If I delete the second button, then the first button is worked.I want to work both buttons.How can I work them?
HTML template IInd_std.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>{{ u }}
<input type="submit" value="present" name="add20"/>
<input type="submit" value="absent" name="add21"/>
{{ v }}
</td>
</tr>
</table>
views.py
u = 1; v = 1
def IInd_std(request):
global u,v
my_dictionary = {
"u" : u, "v" : v
}
if request.GET.get('add20'):
u = u+1
my_dictionary = {
"u" : u,
}
if request.GET.get('add21'):
v = v+1
my_dictionary = {
"v" : v,
}
return render(request, 'blog/IInd_std.html', my_dictionary)
Try changing it to:
request.GET['add20']:
and
request.GET['add21']:
Also, you are re-initializing my_dictionary
in your if statements.
Change it to:
my_dictionary["u"] = u
and
my_dictionary["v"] = v
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.