为什么asp.net隐藏字段变得可见

时间:2013-11-17 09:38:39

标签: javascript asp.net c#-4.0

这是我用来访问值的javascript代码,但每次运行所有隐藏字段变得可见为什么?

function PopulateTableComboBox(ID) {

var myValues = new Array();
var startsWith = "TABLE=";

for (var index = 0; index < document.getElementsByTagName("input").length; index++) {

    if (document.getElementsByTagName("input")[index].type = 'hidden' && document.getElementsByTagName("input")[index].id.substring(0, startsWith.length) === startsWith) {
        myValues.push(document.getElementsByTagName("input")[index].value);
    }
}
       }

甚至视图的隐藏字段也会影响到asp.net按钮变成带有文本的方框。我附上了前后图片this is the before the javascript function is run This is after the javascript function is run

1 个答案:

答案 0 :(得分:2)

您使用=代替==

您的代码

 document.getElementsByTagName("input")[index].type = 'hidden' 

将其更改为

document.getElementsByTagName("input")[index].type == 'hidden'