A Horizontal Percentage Gauge Class

Source: Internet
Author: User
<%
Dim Sl_gauge
Set Sl_gauge = new Slgauge
Sl_gauge. bgcolor = "#FFFFFF"
Sl_gauge. Fgcolor = "#990000"
Sl_gauge. Width = 78
Sl_gauge. Height = 5
Sl_gauge. Minval = 0
Sl_gauge. Maxval = 100
Sl_gauge. Curval = Itestscore ' 87% in our example
%>
<!--Display the gauge-->
<table cellpadding=0 cellspacing=2>
<tr>
<td>0</td>
<td><% = Sl_gauge. Renderhtml%></td>
<td>100%</td>
</tr>
</table>

<%
' Handy class for displaying a horizontal percentage gauge.
%>
<%
Class Slgauge
' Colors.
public bgcolor
Public Fgcolor

' Dimensions.
Public Width
Public Height

' Values.
Public Minval
Public Maxval
Public Curval

' Render this into HTML as a table.
function renderhtml
' Normalize the properties.
If Minval > Maxval Then
Dim Temp_val
Temp_val = Minval
Minval = Maxval
Maxval = Temp_val
End If

If Curval < minval Then
Curval = Minval
ElseIf curval > Maxval Then
Curval = Maxval
End If

' Figure out of the percentage that's curval is
' Within Minval and maxval.
Dim Percentage_val
Percentage_val = (curval-minval)/(Maxval-minval)

' Compute the second widths.
Dim Fg_width
Fg_width = Round (width * percentage_val)
Dim Bg_width
Bg_width = Width-fg_width

renderhtml = "<table cellspacing=0 cellpadding=0 width=" & _
Width & "height=" & Height & ">" _
& "<tr>"
If fg_width > 0 Then
Renderhtml = Renderhtml _
& "<td width=" & Fg_width & "Height=" & _
Height & "Bgcolor=" & Fgcolor & _
"><img src=/demos/images/" & _
"1_pix_trans.gif></td>"
End If
If bg_width > 0 Then
Renderhtml = Renderhtml _
& "<td width=" & Bg_width & "Height=" & _
Height & "Bgcolor=&quo



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.