0

我在这里有这段代码:

var first = orfirst;    
second = eval("document.love.name" +ea).value.toUpperCase();
var names=second;
second = second.replace(r,"");

使用此代码:

("document.love.name" +ea).value.toUpperCase();

我收到一个错误:未捕获的类型错误:无法读取未定义的属性“name1”

在哪里:<input value='' name=name1 onkeyup=checnum(this) type=text size=15>

因为他们说这个代码 id 已被弃用:document.love.name我试着让它像这样:second = eval("document.getElementById('name')" +ea).value.toUpperCase();

然后我得到这个错误: Uncaught SyntaxError: Unexpected number

谁能给我看或更正代码?提前致谢。

4

1 回答 1

2

如何为元素添加 ID 并使用以下代码:

document.getElementById("name"+ea).value.toUpperCase();

感谢@Quentin 和@Prisoner 发现目前没有 ID。

于 2013-01-11T11:28:13.270 回答