Hi , i am using the below script to convert CSV File to HTML Table (Shell Script to be used) , and change the background color of the cell of 1st column, if the value is less than 100 to RED. If the value=100 then as is else RED..Below is the script/code (suggested in one of the Forums) , however the background color remains the same (Lemon Chifon) even for the values less than 100. I am new to HTML..Any help on this will be much appreciated..
BEGIN {
print "<html><head>"
print "<title >Title </title>"
print "<style type=\"text/css\">"
print ".error {
print " color: red,"
print " font-size: larger,"
print "}"
print "</style></head>"
print "<body>"
print "<p>The report provides overall Percentage Secured in the given subjects.</p>"
print "<table border=1 bgcolor=\"LemonChiffon\" cellspacing=1 cellpadding=1>"
}
NR == 1
# Header row
print "<tr>"
print "<th><Score %></th>"
print "<th><Status></th>"
print "<th><Exam Date></th>"
print "<th><Term></th>"
print "<th><Subject></th>"
print "</tr>"
}
NR > 1 {
# Data rows
print "<tr>"
for ( i = 1; i <= NF; i++ ) {
class = $i < 100 ? "class=\"error\"" : ""
printf "<td %s>%s</td>\n", class, $i
}
print "</tr>"
}
Your CSS for .error doesn't change the background color. It only changes the text color and font size. Does the text show in RED?
This is incorrect:
@Charles , No the text color remains the same. it doesn't change... Style attrributes are not getting called i guess . Font/Color/BG-Color everything remains the same..Nothing changes... ..Banging my head..
Christian told you. The delimiter between property-value pairs should be a semicolon. Not a comma as you have it. Lite this.
Thank you so much Christian & Charles.
Christian was right by inserting the correct Background property and <Value> and by replacing the comma with semi colon has done the trick. I am now able to generate the Background color. Thank you once again to both
Lastly one small doubt, how to centre-allign the following Header. It should come on top of the Column headers and centre allign.
print "</p>"report provides overall Percentage Secured in the given subjects"</p>"
Thanks alot...
That's right - just forget about me.
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)