• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

change bgcolor of row dynamically ???

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
document.getElementById("TR_ID").style.background = "#1100FF";
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eric,

Please any suggesstion about my above mentioned situation.

Thanks & Regards
Bikash
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Just the other day, I was thinking ... about this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic