简体   繁体   中英

assigning color from query result to div


I have this query which gets some data from a database including a color in hex format. What I'd like to do is assign the color to a div in my html page.

_sQry = "SELECT TOP 101 dossier_id, dossiernummer_c, inzake_c, ini_notaris_c, behandelaar1.initialen as initialen1, behandelaar1.kleur as kleur1, behandelaar2.initialen as initialen2, behandelaar2.kleur as kleur2 \
        FROM dossier \
        LEFT JOIN medewerker AS behandelaar1 ON dossier.behandelaar1_id=behandelaar1.medewerker_id \
        RIGHT JOIN medewerker AS behandelaar2 ON dossier.behandelaar2_id=behandelaar2.medewerker_id \
        WHERE 1=1 AND {ADDITIONAL_WHERE}";

This is my query, behandelaar1.kleur and behandelaar2.kleur are the colors.

row_24=[E3525DEB-AD4E-4D0F-B3CA-19C97667CAC4, 2013045801, ECH 3 testdossier, JDO, SYS, #00ffff, JU, #ff3333] 

This is an example of a query result with the colors at the end of it.

<article >
<form id="dossier-zoek">
    <input type="text" id="sea" name="search" class="regTXTBOX brdrCol" placeholder="Zoek">
    <button id="searchDos" class="bgCol">Zoek dossiers</button>
</form>
<h2 id="title" style="position:fixed; width:100%;" class="brdrCol txtCol">$!template.dossiers.list_title</h2>

<div id="list" style=" position:fixed; height:auto; width:100%; top:188px; bottom:0px; overflow-y:scroll; -webkit-overflow-scrolling: touch; overflow-x:hidden;">
    <table>
        #foreach($row in $template.dossiers.data.records)
        <tr>
            <td>$!row.dossiernummer_c</td>
            <td>$!row.inzake_c</td>
            <td style="font-weight:bold; color:red;">H</td>
            <td>$!row.ini_notaris_c</td>
            <td id="b1">$!row.initialen1</td>
            <td id="b2">$!row.initialen2</td>
            <td class="icon-gt txtCol"></td>
        </tr>
        #end
    </table>
</div>

and this is my html in which I place the query results, in the with id b1 and b2 I would like to add the colors as a background color.
I have no idea how to get this done and I hope anyone here knows how to do this.

Did you try to set the CSS background-color property? For example:

<td id="b1" style="background-color: $!row.kleur1">$!row.initialen1</td>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM