Histogram Demo

<% @ Language="JavaScript" %>

<HTML>
<HEAD><TITLE>
Histogram Demo</TITLE></HEAD>

<BODY>

CONTENT_LENGTH will only be greater than 0
if we Submitted a Form using the
POST Method.
If this is the case then display the results
Else Display the Form for the User to fill out.

<% if (Request("CONTENT_LENGTH") == 0 ) { %>
            <FORM NAME="aForm" METHOD="POST" ACTION="hist.asp">
                 Input three numbers:
                 <INPUT NAME="V1">
                 <INPUT NAME="V2">
                 <INPUT NAME="V3">
                 <INPUT TYPE="SUBMIT">
            </FORM>
<% }
       else {
            var p1, p2, p3, total;

            total = parseInt(Request("V1")) + parseInt(Request("V2")) + parseInt(Request("V3"))

            p1 = (Request("V1") / total) * 100
            p2 = (Request("V2") / total) * 100
            p3 = (Request("V3") / total) * 100
%>

<IMG SRC="hist.gif" HEIGHT="13" WIDTH=<% = p1 * 5 %>> V1: <% = Math.round(p1) %>%
<IMG SRC="hist.gif" HEIGHT="13" WIDTH=<% = p2 * 5 %>> V2: <% = Math.round(p2) %>%
<IMG SRC="hist.gif" HEIGHT="13" WIDTH=<% = p3 * 5 %>> V3: <% = Math.round(p3) %>%

<% } %>