[Python] How can I change the background color of a column based on the value of another...

Discussão em 'Python' iniciado por Stack, Junho 19, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Django framework. I have a table that contains some columns. I need to change the background of the aht column based on the agent_target column so if the value lower than or equal the target the background should be green, else it should be red.


    {% for item in data %}
    <tr>
    <td class="text-center align-middle">{{ item.loginid }}</td>
    <td class="text-center align-middle">{{ item.agentname }}</td>
    <td class="text-center align-middle">{{ item.team }}</td>
    <td class="text-center align-middle">{{ item.queue_name }}</td>
    <td class="text-center align-middle">{{ item.sumduration}}</td>
    <td class="text-center align-middle">{{ item.countduration}}</td>
    <td class="text-center align-middle aht">{{ item.aht}}</td>
    <td class="text-center align-middle target">{{ item.agent_target}}</td>

    </tr>
    {% endfor %}

    When I try to access the value of the AHT column using the below js it returns undefined value

    console.log(document.getElementById("aht").value)

    Continue reading...

Compartilhe esta Página