首页 > 解决方案 > 计算html表中的唯一值

问题描述

我想计算 html 表中的唯一值。(RGB 颜色)

我正在使用第三方网站,它使用 PHP 在表中写入值。我无权访问 PHP 脚本。

PHP 在这里写“{colorcode}”一个我定义的 rgb-to-hex。我有 5 个十六进制值:
火:#FF8C00
医疗帮助:#FD0202
危险材料:#19070B
其他:#4876FF
技术援助:#0000FF

我的目标是,我可以单独计算每种颜色并将其写在另一个表中。
这是我的网站,其中显示了表格:https
://www.feuerwehr-forstern.de/einsaetze/ 我想计算的表格。

<table>
<tr style="font-size:16px; background-color:#670200; color:#FFFFFF;">
<th><b>Nr.</b></th>
<th><b>Missionstart</b></th>
<th><b>Title</b></th>
<th><b>Kind of mission</b></th>
<th><b>Place</b></th>
<th></th>
</tr>{liststart}
<tr>
<td style="color:#FFFFFF;" bgcolor={colorcode}><b>{missionnr}</b></td>
<td>{startdate} {starttime}</td>
<td>{missiontitle}</td>
<td>{kind of mission}</td>
<td>{missionplace}</td>
<td><u>{linkreport}</u></td>
</tr>{listend}
</table>

其他表,我想在“:”之后写下计数结果。

<table>
<tr style="font-size:16px; color:#FFFFFF;">
<th style="background-color:#FF8C00;"><b>fire:</b></th>
<th style="background-color:#FD0202;"><b>medical help:</b></th>
<th style="background-color:#19070B;"><b>hazardous materials:</b></th>
<th style="background-color:#4876FF;"><b>other:</b></th>
<th style="background-color:#0000FF;"><b>technical assistance:</b></th>
</tr>
</table>

标签: javascriptjqueryhtmlhtml-table

解决方案


你可以试试这个:var blue_count = $('[bgcolor=#0000FF]').length获取属性值为的td元素的计数。然后你可以在任何你想要的地方附加计数值。bgcolor#0000FF

但这只是你解决它的想法......不是最好的方法......

祝你好运


推荐阅读