You are viewing limited content. For full access, please sign in.

Question

Question

Change Table Row color based on a column being checked or not

asked on November 20, 2023 Show version history

Hello all.  I am trying to get my form to change the color of either the row or the fonts in the row when the check box in the 'Use' column is checked.

Currently, I was able to get the font to change color when a value in the Column Brand name is changed to Archwire.  In the end though, I need the check box 'Use' to be the trigger, not the dropdown under Brand name.  Can someone help me with how to refence a check box being checked?

 

CSS

tr.RedRow {color:#f00;}
tr.RedRow input, tr.RedRow select {color:#f00;}

 

$(document).ready( function() {
 
$('.MyTable').on('change','.ColorSelect select', function() {
    if ($(this).val() == "Archwire"){
        $(this).closest("tr").addClass("RedRow");
    }else{
        $(this).closest("tr").removeClass("RedRow");
    }
});
     
});
0 0

Answer

SELECTED ANSWER
replied on November 21, 2023 Show version history

Can set javascript like this:
'ColorCheckbox' is css name configured for checkbox "Use"

$(document).ready( function() {
 
$('.MyTable').on('change','.ColorCheckbox input', function() {
    if ($(this).is(':checked')){
        $(this).closest("tr").addClass("RedRow");
    }else{
        $(this).closest("tr").removeClass("RedRow");
    }
});
     
});
1 0
replied on November 21, 2023

That was exactly what I needed.  Thank you!

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.