Reputation:
What is the best way to disable the "deny" button when "approve" button is clicked ? I have {{some}} that stores the value of approve or deny value.
<a href="{% url 'hrfinance:edit' id=item.id status='a' %}"><button>Approve</button></a>
<a href="{% url 'hrfinance:edit' id=item.id status='d' %}"><button>Deny</button></a>
html file
{% if some %}
<table id="example" class="display" cellspacing="0" width="100%" border="1.5px">
<tr align="center">
<th> Student ID </th>
<th> Student Name </th>
<th> Start Date </th>
<th> End Date </th>
<th> Action </th>
<th> Status </th>
</tr>
{% for item in query_results %}
<tr align="center">
<td> {{item.studentID}} </td>
<td> {{item.studentName}} </td>
<td> {{item.startDate|date:'d-m-Y'}} </td>
<td> {{item.endDate|date:'d-m-Y'}} </td>
<td><a href="{% url 'hrfinance:edit' id=item.id status='a' %}"><button>Approve</button></a> <a href="{% url 'hrfinance:edit' id=item.id status='d' %}"><button {% if some == 'approve' %} disabled{% endif %}>Deny</button></a></td>
<td>
{% if item.status %}
{{item.status}}
{% else %}
Pending
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% else %}
the {{some}} gets from here
views.py
def superltimesheet(request):
query_results = Timesheet.objects.all()
data={'query_results':query_results, 'some':'some'}
return render(request, 'hrfinance/supervisor_list_timesheet.html', data)
Upvotes: 1
Views: 6152
Reputation: 4213
I am not sure about what are you asking, but you can do an if statement like
{% if some == 'approve' %}
<a href="{% url 'hrfinance:edit' id=item.id status='d' %}"><button>Deny</button></a>
{% else %}
<a href="{% url 'hrfinance:edit' id=item.id status='a'%}"><button>Approve</button></a>
{% endif %}
or:
{% if some == 'approve' %}
<button>Deny</button>
{% else %}
tell me if that works or I misunderstood
Upvotes: 1
Reputation: 8061
Use an if
tag:
<button{% if some == 'deny' %} disabled{% endif %}>Approve</button>
Upvotes: 6