Webページで条件付き書式を適用して3つの書式設定規則を割り当てるようにしました(CSSクラス 'good'、 'bad' 、 '満足のいく')、表の第2列のセルと表の最後の行に対応するセルとを比較することによって、2列目の各セルと最後の行の対応セルとを比較した条件付き書式
は、画像内の細胞間の比較の詳細を参照してください細胞場合 rule to compare cells in table
in words:
- は(2,2)セル(9,3) とセル(2,2)比較しますセル(9,3)の背景をセル(9,3)の緑色(class = 'good')に変更し、IFセル(2,2)>セル(9,3) セル(2,2)とセル(9,3)を比較する。
- セル(3,2)をセル(9,4)と比較する
- は ..until私はこのJavascriptを試み、それがセル(9,9)
とセル(8,2)を比較(9,5)セルとセル(4,2)を比較します動作していない:
function realizat() {
for (i = 2; i < 9; i++) {
if (document.getElementById('GridView1').rows[i].cells[2] < document.getElementById('GridView1').rows[9].cells[i + 1]) {
document.getElementById('GridView1').rows[9].cells[i + 1].addClass = ('bad')
}
}
それは理にかなっている場合は、HTMLページ内のテーブルの定義を「GridView1は」
<table class="containerComisionare" cellspacing="0" cellpadding="1" id="GridView1" style="width:400px;border-collapse:collapse;">
<tr style="color:Black;background-color:White;border-style:None;font-family:Segoe UI;font-size:8pt;font-weight:normal;">
<th scope="col">Ziua Planificare</th><th scope="col">Target (Soll)</th><th scope="col">Realizat (Ist) Vineri</th><th scope="col">Realizat (Ist) Sambata</th><th scope="col">Realizat (Ist) Duminica</th><th scope="col">Realizat (Ist) Luni</th><th scope="col">Realizat (Ist) Marti</th><th scope="col">Realizat (Ist) Miercuri</th><th scope="col">Realizat (Ist) Joi</th><th scope="col">Realizat (Ist) Total</th>
</tr><tr align="center" style="border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Vineri</td><td>134</td><td>134</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>134</td>
</tr><tr align="center" style="background-color:White;border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Sambata</td><td>55</td><td>60</td><td>55</td><td> </td><td> </td><td> </td><td> </td><td> </td><td>115</td>
</tr><tr align="center" style="border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Duminica</td><td>45</td><td> </td><td> </td><td>39</td><td>4</td><td> </td><td> </td><td> </td><td>43</td>
</tr><tr align="center" style="background-color:White;border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Luni</td><td>32</td><td> </td><td> </td><td> </td><td>32</td><td> </td><td> </td><td> </td><td>32</td>
</tr><tr align="center" style="border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Marti</td><td>7</td><td> </td><td> </td><td> </td><td> </td><td>7</td><td> </td><td> </td><td>7</td>
</tr><tr align="center" style="background-color:White;border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Miercuri</td><td>4</td><td> </td><td> </td><td> </td><td> </td><td> </td><td>4</td><td> </td><td>4</td>
</tr><tr align="center" style="border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Joi</td><td>5</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>5</td><td>5</td>
</tr><tr align="center" style="background-color:White;border-width:1px;border-style:Solid;font-family:Segoe UI;font-size:8pt;">
<td>Total</td><td> </td><td>194</td><td>55</td><td>39</td><td>36</td><td>7</td><td>4</td><td>5</td><td> </td>
</tr>
</table>
されたHTMLテーブルはASP GridVから出てきますコントロールの表示
<asp:GridView ID="GridView1" runat="server" ClientIDMode="Static" CellPadding="1" GridLines="None" Width="400px" CssClass="containerComisionare">
<AlternatingRowStyle BackColor="white"/>
<HeaderStyle BackColor="White" Font-Names="Segoe UI" Font-Size="8pt" ForeColor="Black" Font-Bold="False" BorderStyle="None" />
<RowStyle Font-Names="Segoe UI" Font-Size="8pt" HorizontalAlign="Center" BorderStyle="Solid" BorderWidth="1px"/>
</asp:GridView>
私が説明したこの条件付き書式を達成するのを手伝ってください。
私はJavascriptに新しいです。私はページの
の領域内の機能で引用されたコードを置きます。私は何か別のことをする必要がありますか? htmlページのの中の関数を呼び出す必要がありますか? – peppe1私はまだ – peppe1
は、私はあなたの最後の変化に応じて編集した後、ファビオが。それはまだ動作していない私を助けてくれてありがとう動作しません、テーブルのIDである「GridView1" にIDを変更しました。私はでテーブル定義を入力します質問、それは場合に役立ちます私は代わりのinnerTextの複数のバリエーションを試してみました、.VALUEと同じコードをしました;。のparseInt(...テキスト())と、それが動作しないのいずれか – peppe1