2

そのテーブルの td の入力フィールドの id を使用して、html テーブルで行を動的に作成しています。新しく追加された行と入力ボックス ID も作成されたテーブルが適切に作成されましたが、ID を使用してその入力ボックスを取得しようとすると、null 例外がスローされます。

var cell1 = row.insertCell(1);
var element1 = document.createElement("input");
    element1.name = rId + "_" + rowCount + "_newscheduledate";
    element1.id = rId + "_" + rowCount + "_newschedueldate";
    cell1.appendChild(element1);

     alert(rowCount+"  : "+rId);  //here alert shows the values
     var tt = document.getElementById(rId + '_' + rowCount + '_newscheduledate');
     alert(tt); // here null comes

例外はこのようになります

Error: document.getElementById(rId + ("_" + rowCount + "_newscheduledate")) is null
4

2 に答える 2

1

スペルミスがあります

element1.id = rId + "_" + rowCount + "_newschedueldate";

する必要がある

element1.id = rId + "_" + rowCount + "_newscheduledate";

于 2013-02-23T09:00:15.483 に答える
1

変化する:-

element1.id = rId + "_" + rowCount + "_newschedueldate";

element1.id = rId + "_" + rowCount + "_newscheduledate";
于 2013-02-23T08:53:35.497 に答える