jsp里用javascript的键盘事件

function checkpsd() {
if(event.keyCode=="66")
{

document.getElementById("discount").focus();

document.form.discount.value="";

}
}
我输入键盘B触发事件checkpsd焦点位于discount文本框里,但触发事件也把B这个字母也填充到了discount这个文本框里面
,请问触发B键盘事件,焦点位于discount,要把discount这个值清空怎么清?

你是使用onkeydown事件吧,改成onkeyup事件即可

setTimeout(checkpsd,0);
function checkpsd() {
if(event.keyCode=="66")
{

document.getElementById("discount").focus();

//document.form.discount.value="";

}
}

discount文本框设置为空值不应该是
这样把:document.form.discount.value="";
我记得应该是把长度设置为0吧?
document.form.discount.length=0;
这才是清空吧?

document.form.discount.value=""; 没见过!!!! [color=red]/(^_^)[/color]

可行的:
var tem=document.getElementById("discount");
tem.value="";
tem.focus();

要触发调用这个函数。可以使用事件也可以自己另外注册一个监听器。。