Java脚本:Uncaught TypeError: Cannot read property 'value
Java Script: Uncaught TypeError: Cannot read property 'value' of undefined
如果我这个问题是重复的,我很抱歉,我已经阅读了所有的Q &A在网站上查询但没有找到答案。
我得到错误信息Uncaught TypeError: Cannot read property 'value' of undefined
。有趣的是,这只适用于一个客户。我已经创建了一个地方,我们可以输入客户的到达和离开信息,但是一旦我们添加一个客户端,它将为其他客户端带来良好的工作。我已经检查了办公室所有的电脑,但是我仍然不能把XYZ先生加到到达名单中。
这一行
var fldQPRArrivalFlightID=document.getElementsByName('fldQPRArrivalFlightID['+fldCustomerReservationID+']['+mycount+']')[0].value;
方法getElementsByName(..)
不返回数组-或空数组。因此,getElementsByName(..)[0]
是undefined
,您将收到错误。
你可以尝试记录'fldQPRArrivalFlightID['+fldCustomerReservationID+']['+mycount+']'
的返回值,并验证getElementsByName( returnvalue )
的调用应该返回什么。
代替你的代码:
fldQPRArrivalFlightID=document.getElementsByName('fldQPRArrivalFlightID['+fldCustomerReservationID+']['+mycount+']')[0].value;
试
console.log( fldCustomerReservationID );
console.log( mycount );
console.log( 'fldQPRArrivalFlightID['+fldCustomerReservationID+']['+mycount+']' );
console.log( document.getElementsByName('fldQPRArrivalFlightID['+fldCustomerReservationID+']['+mycount+']') );
我真的很惊讶这些引用都是正确的。
相关文章:
- $(this).prop('property') vs. this.property
- 在ember/handlers中使用value和valueBinding有什么区别
- 需要url导航从DropDown Value onClick按钮传递url变量
- 用Javascript在下拉列表中选择VALUE选项
- JQuery .sort() JavaScript Object by property value不起作用
- 使用$(“[property=value]”).click(),我希望两次单击之间有一个延迟
- 无法读取property 'value'形式中未定义的错误
- 为什么我得到"TypeError: Cannot read property 'value'n
- javascript无法获取property 'value'未定义或空引用的
- AngularJS选择property的value而不是object
- 不能设置property 'value'输入为null
- 未捕获的TypeError: Cannot read property '1'未定义的,使用value作
- 提交时,JSON数据返回:"Cannot read property 'value'undef
- Java脚本:Uncaught TypeError: Cannot read property 'value
- 无法读取property 'value'零
- 不能设置property 'value'javascript中的null
- Javascript无法读取property 'value'零
- 不能设置property 'value'当使用getElementById时,返回null
- SCRIPT5007:无法获取property 'value'在IE10中未定义或空引用
- SCRIPT5007:无法获取property 'value'在IE11中未定义或空引用