表单动态计算

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立刻计算出结果
...全文
98 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
  • 打赏
  • 举报
回复
+? -? *? /? 什么运算?

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧