在表单中及时运算

yidao2004 2004-05-04 06:54:48

1 一个表单一共三个文本框

1)数量 2) 单价 3) 总额

2 要实现的功能

在数量框内和单价框内输入相应的值后,总额的值自动填充

假如:数量为8;单价为10;那么总额相应的就应该自动填充为80

...全文
90 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yidao2004 2004-05-05
  • 打赏
  • 举报
回复
问题继续:

如果在加2个变量,如何控制

1 增加一个应付总额和备注变量

2 如果应付总额等于总额,那么备注的内是:完全支付
如果应付总额<总额,那么备注的内容是:你已经支付了(应付的)元,还有(总额-应付)未支付
如果应付总额>总额:alert(“对不起,你输入的数据有错误,请检查”)
edolphin 2004-05-04
  • 打赏
  • 举报
回复
同意楼上的写法!用脚本语言就可以实现
wanghr100 2004-05-04
  • 打赏
  • 举报
回复
数量<input type="text" name="Text1" onkeyup=baototal()>
单价<input type="text" name="Text2" onkeyup=baototal()>
总额:<input type="text" name="sum">
<script>
function baototal()
{
var total=0;
total = document.all.Text1.value*document.all.Text2.value;
document.all.sum.value=total;
}
</script>
stayhere 2004-05-04
  • 打赏
  • 举报
回复
<input type=text id=txt_num onChange="GetTotal()">
<input type=text id=txt_price onChange="GetTotal()">
<input type=text id=txt_total>

<script language=vbscript>
sub GetTotal()
if not isnumeric(txt_num.value) or not isnumeric(txt_price.value) then
txt_total.value=""
exit sub
else
txt_total.value=cdbl(txt_num.value) * cdbl(txt_price.value)
end if
end sub
</script>
liuyu202 2004-05-04
  • 打赏
  • 举报
回复
用javascript容易实现阿!

28,409

社区成员

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

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