my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes change bgcolor of row dynamically ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "change bgcolor of row dynamically ???" Watch "change bgcolor of row dynamically ???" New topic
Author

change bgcolor of row dynamically ???

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi,

I want to change the bgcolor of row dynamically depends on condition of values of two columns of row. Actually Iam comparing values of two columns and depend on the result of comparison i want to change the bgcolor of that row.

Can any one please help me in this regard.

Thanks & Regards
Bikash
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
document.getElementById("TR_ID").style.background = "#1100FF";
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi Eric,

First of all thanks for the reply.In my JSP page the ROW for which iam trying to change the background color dynamically that ROW have class attribute also due to which my below code is not working.And in my JSP code that class attribute also require. Can u please guide me how i can slove this problem.


<TR class="row" id = "aROW" >
if(<%=strFinalValue%> <= <%=pf.getstrCost()%> { document.getElementById('aRow<%=i+1%>').style.background = "#1100FF";
}

If I remove the class attribute from ROW then it start working but my requirement is the rows which match the above mentioned condition only those row's bgcolor should change and other rows should implement that class.In my JSP page iam creating rows dynamically.

Thanks & Regards
Bikash
[ June 30, 2004: Message edited by: Bikash Paul ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to change the row with a style attribute, you can add your if statement to write this inside of the tag.

<TR class="row" id = "aROW" style="background:#112233">
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi Eric,

I think u r not getting me .Iam explaining my situation.

Below r my code :-

for (i=0; i< arySelectedProductDtls.length; i++){LPFactorVO pf = (LPFactorVO)arySelectedProductDtls[i];

String row = "swb-row1";
if(i%2==0){
row = "swb-row1";
}
else{
row = "swb-row2";
}

<TR class="<%=row%>" id="aRow" >

<!--for checkbox --->
<TD><!--some code here--></TD>

<!--for item name-->
<TD><!--some code here--></TD>

<!--For Price-->
<TD><!--some code here--></TD>
<SCRIPT>
if(<%=strFinalValue%> <= <%=pf.getstrCost()%> { document.getElementById('aRow<%=i+1%>').bgcolor = 'brown';
}
</SCRIPT>

</TR>

}//end of for loop


Here is my two css class in my css file:-

.swb-row1{
background-color: #ffffff;
font-size: 8pt;
}

.swb-row2{
background-color: #eeeeee;
font-size: 8pt;
}

Iam actually showing row's bgcolor alternatively in different color.Now in last column iam checking one condition which comparing two values and if that condition match then only that row's bgcolor should change to different color.Now i think it is clear to u what iam exactly want to do.

Thanks & Regards
Bikash
[ June 30, 2004: Message edited by: Bikash Paul ]
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi Eric,

Please any suggesstion about my above mentioned situation.

Thanks & Regards
Bikash
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi Eric,

I have sloved that problem of bgcolor of ROW dynamically as per ur suggesstion. But Now iam facing with another problem in my column there is a text box and that text box having css class for that when i changed the color of whole row that does not reflect on bgcolor of text box.Can you please guide me when i change the bgcolor of whole row that should also change the bgcolor of text box.

Below r my codes:-

<TD><INPUT type="text" class="readonly1" ......></TD>

Here is my css class in css file :-

.readonly1
{
font-family: "Arial, Helvetica";
font-size: 8 pt;
color: #000000;
text-decoration: none;
background-color: #ffffff;
border-color: #EFEFEF #EFEFEF #EFEFEF #EFEFEF;
border-style: solid;
border-top-width: 0 px;
border-right-width: 0 px;
border-bottom-width: 0 px;
border-left-width: 0 px;
height: 15 px;
}
Thanks & Regards
Bikash
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
quick fix would be to set the background color of the textbox to transparent, but not sure if it works in all browsers.

background:transparent;

Play with that.
 
wood burning stoves
 
subject: change bgcolor of row dynamically ???