简体   繁体   English

Javascript-GetColoumnValue-IE6问题

[英]Javascript - GetColoumnValue - IE6 problem

I have a js function named "GetListColumnValue". 我有一个名为“ GetListColumnValue”的js函数。 This function causes some problems with IE6. 此功能导致IE6出现一些问题。 Is there any way to avoid the problem? 有什么办法可以避免这个问题? (I thnk the problem is occured because of the concat) Here is the code sample. (我认为问题是由于concat而发生的)这是代码示例。 The last line is my solution which I am not sure that it works well. 最后一行是我的解决方案,我不确定它是否运行良好。 Any suggestions? 有什么建议么? Thanks. 谢谢。

function GetListColumnValue(listName, columnName) {
    return document.getElementById(listName + "_" + columnName).value;
}
var DISCOUNT_QUANTITY = GetListColumnValue("lstRecords", "DISCOUNT_QUANTITY"); 

var DISCOUNT_QUANTITY = document.getElementById("lstRecords_DISCOUNT_QUANTITY");

IE6 has many many problems, but simple JS string concat isn't one of them. IE6有很多问题,但是简单的JS字符串连接并不是其中之一。 I don't think that's your problem. 我不认为这是你的问题。

You didn't specify what exactly the problem is, but looking at the two code samples you provided, they will do different things: 您没有指定确切的问题是什么,但是查看您提供的两个代码示例,它们将做不同的事情:

The first one (ie the function) returns the object.value, whereas the second one (ie setting it directly), you've just returned the object. 第一个(即函数)返回object.value,而第二个(即直接设置),您刚刚返回了对象。

So the two code blocks set DISCOUNT_QUANTITY to different things. 因此,这两个代码块将DISCOUNT_QUANTITY设置为不同的内容。 If you remove the .value from the function, it should work exactly the same as the other code block. 如果从函数中删除.value,则它应与其他代码块完全相同。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM