Dynamic CSS in Classic ASP

-1

People .. I have a web site in classic asp that revercute a table that is updated daily in the SQL server.

Then I have a column in the table named column1 that shows values from 0 to 120

In my asp, this column is shown in formatnumber (RSK ("column1"), 2)% >

(RSK is the query that shows the data in the table)

so far, but I want to put a condition that if the displayed values are from 0 to 50, appear in a color, if the data is from 51 to 100 appear in a second color and if they are from 101 to 120, appear in a third color.

How do I change the CSS class depending on the data shown in the table?

I tried to do this to see if I could achieve at least one of the conditions:

<% col1 =Request.Querystring("col1") If (col1>="100") then Response.Write("td{font-color:blue;}"); End If %> 

But it did not work. "Expected end of statement"

    
asked by anonymous 23.08.2018 / 21:14

1 answer

0

Maybe by the time you've already found the solution, but here's a suggestion of something to do:

<html>
<body>

<style>
.cor0a50 { color: blue }
.cor51a100 { color: green }
.cor101a120 { color: orange }
</style>

<script type="text/vbscript">
col1 = Request.Querystring("col1")

if Trim(col1) <> "" then

    col1 = CInt(col1)

    if col1 <= 50 then
        classeEstilo =  "cor0a50"
    elseif col1 >= 51 and col1 <= 100 then
        classeEstilo =  "cor51a100"
    elseif col1 >= 101 and col1 <= 120 then
        classeEstilo =  "cor101a120"
    end if
else
    document.write ("variável col1 não encontrada")
end if

document.write("<table><tr><td class="&classeEstilo&">"&classeEstilo&"</td></tr></table>")
</script>

</body>
</html>
    
22.10.2018 / 16:03