百分比的相互转换,计算一些小数据还是非常方便的,实用

- 中国WEB开发者网络 (http://www.webasp.net)
-- 网页特效 (http://www.webasp.net/javascript/)
--- 百分比的相互转换,计算一些小数据还是非常方便的,实用 (http://www.webasp.net/javascript/1/684.htm)
-- 发布日期: 2005-06-29
<!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! -->
<!-- 要实现此效果需要 1 个步骤: -->

<!-- 第 1 步: -->
<!-- 把下面的代码加到<BODY></BODY>区域中: -->

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function calc1(form) {
a = form.a.value/100;
b = a*form.b.value;
form.total1.value = b;
}
function calc2(form) {
a = form.c.value;
b = form.d.value;
c = a/b;
d = c*100;
form.total2.value = d;
}

// End -->
</script>
<form name="form1">
<table border=1 cellpadding=4 cellspacing=1>
<tr>
<td align=center><input type="text" name="b" size=5>的
<input type="text" name="a" size=5>
% 是多少 ?</td>
<td align=center>答案: <input type="text" name="total1"
size=5 maxlength=40></td>
<td align=center><input type="button" value="Calculate"
onClick="calc1(this.form)"></td>
</tr>
<tr>
<td align=center colspan=3 align=center>Or...</td>
</tr>
<tr>
<td align=center><input type="text" name="c" size=5>
是<input type="text" name="d" size=5>的百分之几?</td>
<td align=center>答案: <input type="text" name="total2"
size=5> %</td>
<td align=center><input type="button" value="Calculate"
onClick="calc2(this.form)"></td>
</tr>
</table>
</form>


webasp.net