cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

If statement in HTML Text

Hello there!

I am having some HTML code to export information from a gallery. I want the background to be changed green or red depending on whether is true or false. The whole thing works but we just need to have a condition and change the background of the information in the columns. How can I do this? I think it's either th or td that we have to change

Here is my code;

"<html>
<head>   
    <style>
    table {
        width: 100%;
        border-collapse: collapse;
        text-align: center;
    }

    th, td {
        text-align: center;
        border: 1px solid black;
        font-size: 12px;
    }

    h1{
        color:#325ca8;
        }

    tr:nth-child(even){background-color: #f2f2f2}

    th {
        background-color: #325ca8;
        color: white;
    }

    </style>
    </head>
    <body>
    <H1>Project " & DropdownOrder.SelectedText.Result & "-" & DropdownDeelorder.Selected.Result & "</H1>
    <Table>
    <tr><th>Verdieping</th>
    <th>UniekNummer</th>
    <th>Geopperd</th>
    <th>GeopperdDatum</th>
    <th>Gemonteerd</th>
    <th>GemonteerdDatum</th>
    <th>Opgeleverd</th>
    <th>OpgeleverdDatum</th>
    <th>Aantal</th></tr>
    " & Concat(
    Gallery3.AllItems;
    "<tr><td>" & Verdieping &  "</td><td>"
    & UniekNummer & "</td><td>"
    & Geopperd & "</td><td>" 
    & GeopperdDatum & "</td><td>" 
    & Gemonteerd & "</td><td>" 
    & GemonteerdDatum & "</td><td>" 
    & Opgeleverd2 & "</td><td>" 
    & OpgeleverdDatum & "</td><td>"
    & Aantal & "</td></tr>"
) & "
</table>
</body>
</html>
"

 

2 REPLIES 2
gabibalaban
Dual Super User
Dual Super User

Hi @Anonymous ,

Definitively the <td>.

Here is some hints:

ForAll(
        Gallery3.AllItems,
        With(
            {border: If(condition,"green","red")},
            "<td style='background-color:" & border & "'>" & ColumnName & "</td>"
        )
    ),
    Value
) 

 

Anonymous
Not applicable

How would I implement that into the HTML I have right now? I can't seem to get it working

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,609)