我这里有这段代码:
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
有人可以告诉我或更正代码吗? 提前致谢。
最佳答案
向元素添加 ID 并使用以下代码怎么样:
document.getElementById("name"+ea).value.toUpperCase();
感谢 @Quentin 和 @Prisoner 发现目前没有 ID。
关于javascript - 未捕获的语法错误 : Unexpected number,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14277208/