至少有两个错误:
1. 文本框没有 onkeyup 事件
2. 文本框的 name 与你自定义的函数同名, 系统无法正确得知你调用的是控件还是函数<script language="JavaScript">
function total2(form)
{
setTimeout("document.all.price.innerText = document."+ form.name +".total.value");
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="44%">
<input type="text" name="total" onkeydown="total2(this.form)">
</td>
<td width="56%">
<div id="price"> </div>
</td>
</tr>
</table>
</form>
1. 文本框没有 onkeyup 事件
2. 文本框的 name 与你自定义的函数同名, 系统无法正确得知你调用的是控件还是函数<script language="JavaScript">
function total2(form)
{
setTimeout("document.all.price.innerText = document."+ form.name +".total.value");
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="44%">
<input type="text" name="total" onkeydown="total2(this.form)">
</td>
<td width="56%">
<div id="price"> </div>
</td>
</tr>
</table>
</form>
解决方案 »
- Uncaught TypeError: Object function (a,b){return new c.fn.init(a,b)} has no meth
- 关于可拖动拉伸div
- 文本编辑器CKeditor插入图片的问题
- AjaxFileUpload上传图片遇到的问题。
- js 连续计算为什么不对啊,谢谢, 三个
- 跪求做和算法a+b+c=d
- 关于得到Span属性值得问题急在线等待
- 如何加,request头部信息?
- 急!!请问:在vbscript中如何嵌套javascript的代码,即vbscript中要使用javascript中变量的值?
- vue报错之Duplicate keys detected: '0'. This may cause an update error.
- 一个简单的问题~~
- 如何使用键盘事件(onkeydown)实现焦点移到表格的下一行(或上一行){不好意思只有十分了}
<script language="JavaScript">
function total(form,i){
total="total"+i
price ="price"+i
document.all.price.innerText=form.total.value
}
</script><body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="44%">
<input type="text" name="total1" onkeyup="total(this.form,1)">
</td>
<td width="56%">
<div id="price1"> </div>
</td>
</tr> <td width="44%">
<input type="text" name="total2" onkeyup="total(this.form,2)">
</td>
<td width="56%">
<div id="price2"> </div>
</td>
</tr> </table>
</form>
<script language="JavaScript">
function total(form,i){
total="total"+i
price ="price"+i
document.all.price.innerText=form.total.value
}
</script><body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="44%">
<input type="text" name="total1" onkeyup="total(this.form,1)">
</td>
<td width="56%">
<div id="price1"> </div>
</td>
</tr> <td width="44%">
<input type="text" name="total2" onkeyup="total(this.form,2)">
</td>
<td width="56%">
<div id="price2"> </div>
</td>
</tr> </table>
</form>
所以说楼主, 你不能用 onkeyup 这个事件了
function total(form,i)
{
setTimeout("document.all.price"+i+".innerText = document."+ form.name +".total"+i+".value");
}
</script><body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="44%">
<input type="text" name="total1" onkeydown="total(this.form,1)">
</td>
<td width="56%">
<div id="price1"> </div>
</td>
</tr> <td width="44%">
<input type="text" name="total2" onkeydown="total(this.form,2)">
</td>
<td width="56%">
<div id="price2"> </div>
</td>
</tr> </table>
</form>