Function trim (STR)
{
VaR S = STR;
VaR I, Len;
VaR hasempty = false;
If (S. charat (0) = "")
{
S = S. Replace ("","");
Hasempty = true;
}
Len = S. length;
If (S. charat (len-1) = "")
{
S = S. Replace ("","");
Hasempty = true;
}
If (hasempty = true)
{
S = trim (s );
}
Else
{
Return S;
}
}
<HTML>
<Head>
<Title> pie chart </title>
<SCRIPT>
Function drawpiechart ()
{
VaR totalvalue = value1.value/360 + value2.value/360 + value3.value/360 + value4.value/360;
VaR Per1 = value1.value/totalvalue;
VaR per2 = value2.value/totalvalue;
VaR per3 = value3.value/totalvalue;
VaR per4 = value4.value/totalvalue;
VaR per12 = Per1 + per2;
VaR per123 = Per1 + per2 + per3;
Chart. innerhtml = "<Object ID = 'piechar' classid = 'clsid: 2017303c2-d7ac-11d0-89d5-00a0c90833e6 'style = 'position: relative; top: 0; left: 0; width: 400; height: 400 '> <Param name = 'line0001' alue = 'setlinecolor (255, 0,127) '> <Param name = 'line0002' value = 'setfillstyle (1) '> <Param name = 'line0003' value = 'setfillcolor (0,255, 80)'> <Param name = 'line0004' value = 'pie (-100,-100,200,200, 0, "+ Per1 +", 0) '> <Param name = 'line0005' value = 'setfillstyle (1) '> <Param name = 'line0006' value = 'setfillcolor (0, 0,255) '> <Param name = 'line0007' value = 'pie (-100,-100,200,200, "+ Per1 +", "+ per2 +", 0) '> <Param name = 'line0008' value = 'setfillstyle (1)'> <Param name = 'line0009' value = 'setfillcolor (0,128,128) '> <Param name = 'line0010' value = 'pie (-100,-100,200,200, "+ per12 +", "+ per3 +", 0) '> <Param name = 'line0011' value = 'setfillstyle (1)'> <Param name = 'line0012 'value = 'setfillcolor (255, 0, 0) '> <Param name = 'line0013' value = 'pie (-100,-100,200,200, "+ per123 +", "+ per4 +", 0) '> </Object>"
}
</SCRIPT>
</Head>
<Body>
<Table border = 1 width = 100%>
<Tr> <TD id = "chart" width = 50% Height = 400 align = center>
Prepare drawing... </TD>
<TD width = 50%>
<P align = center>
Enter 4 numbers <br>
<Input id = "value1" type = text size = 6 value = 0>
<Input id = "value2" type = text size = 6 value = 0>
<Input id = "value3" type = text size = 6 value = 0>
<Input id = "value4" type = text size = 6 value = 0>
</P>
<P align = center>
<Input type = button onclick = "drawpiechart ()" value = "Pie Chart">
</P>
</TD>
</Tr>
</Table>
</Body>
</Html>