微笑的黄捷

asp.net 资料收集

一个用JavaScript去除字符串两端空格的function

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>饼图</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='PieChart' CLASSID='CLSID:369303C2-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>
准备画图。。。</td>
<td width=50%>
<p align=center>
输入4个数<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="画饼图">
</p>
</td>
</tr>
</table>
</BODY>
</HTML>

阅读更多
个人分类: JAVASCRIPT
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭