2015-11-19 11:05:06
存在问题:
如何实现JS的加和
解决方案:
代码如下
<script type="text/javascript">
function sumH() {
var sunHezhi = 0;
var SXZ = document.getElementById("TextBox1").value; //textbox取值
for (var i = 1; i < SXZ; i++) {
sunHezhi += 1.0 / (i * i);
sunHezhi = parseFloat(sunHezhi); //数字转换
}
alert(sunHezhi.toFixed(2));
}
</script>
<asp:Button ID="Button1" runat="server" OnClientClick="sumH()" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>