表单动态计算

ipan 2008-04-14 11:25:22
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>A
<input type="text" name="A" id="A" /></td>
<td>B
<input type="text" name="B" id="B" /></td>
</tr>
</table>
C=
<input type="text" name="C" id="C" />
实现用户在A,B中输入,C立刻计算出结果
...全文
40 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zl_c 2008-04-15
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>简易计算</title>
</head>
<script language="javascript">
function ShowRe()
{
document.getElementById("C").value = Number(document.getElementById("A").value) - Number(document.getElementById("B").value)
}
</script>
<body >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>A <input type="text" name="A" value="0" id="A" onkeyup="ShowRe()" /> </td>
<td>B <input type="text" name="B" value="0" id="B" onkeyup="ShowRe()" /> </td>
</tr>
</table>
C=<input type="text" name="C" id="C" value="0" />
</body>
</html>
回复
ipan 2008-04-15
你给的代码出错了
回复
zl_c 2008-04-14

function ShowRe()
{
document.getElementById("C").value = Number(document.getElementById("A").value) - Number(document.getElementById("B").value)
}
回复
zl_c 2008-04-14
减法的:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>简易计算</title>
</head>
<script language="javascript">
function ShowRe()
{
document.getElementById("C").value = Number(document.getElementById("A").value) - Number(document.getElementById("B").value)
}
</script>
<body >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>A <input type="text" name="A" value="0" id="A" onkeyup="ShowRe()" /> </td>
<td>B <input type="text" name="B" value="0" id="B" onkeyup="ShowRe()" /> </td>
</tr>
</table>
C=<input type="text" name="C" id="C" value="0" />
</body>
</html>
回复
zl_c 2008-04-14
做加法的:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>简易计算</title>
</head>
<script language="javascript">
function ShowRe()
{
document.getElementById("C").value = Number(document.getElementById("A").value) + Number(document.getElementById("B").value)
}
</script>
<body >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>A <input type="text" name="A" value="0" id="A" onkeyup="ShowRe()" /> </td>
<td>B <input type="text" name="B" value="0" id="B" onkeyup="ShowRe()" /> </td>
</tr>
</table>
C=<input type="text" name="C" id="C" value="0" />
</body>
</html>
回复
ipan 2008-04-14
-
回复
zl_c 2008-04-14
+? -? *? /? 什么运算?
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-04-14 11:25
社区公告
暂无公告