我正在开发一个 asp-net 6 razor 应用程序,我用 javascript 在一个页面中构建了一个表,这是我的代码:
function Importariga(){
var tableart = document.getElementById('CorpoArticoli');
let progr = document.getElementById('proArt').value;
var myTd,myInput;
var myTr = document.createElement('tr');
myTr.setAttribute('class','unit-table');
myTd = document.createElement('td');
myInput = document.createElement('input');
myInput.setAttribute('id','Cek' + progr);
myInput.setAttribute('name','Cecking' + progr);
myInput.setAttribute('class', 'form-check-input me-1');
myInput.setAttribute('style', 'width:25px; height:25px');
myInput.setAttribute('type', 'checkbox');
myTd.appendChild(myInput);
myTr.appendChild(myTd);
myTd = document.createElement('td');
myInput = document.createElement('input');
myInput.setAttribute('id','Cod' + progr);
myInput.setAttribute('name','Codice' + progr);
myInput.setAttribute('value', document.getElementById('idArt').value);
myInput.setAttribute('class', 'form-control border-0');
myInput.setAttribute('style', 'background-color:transparent; width:60px');
myInput.setAttribute('disabled', 'disabled');
myTd.appendChild(myInput);
myTr.appendChild(myTd);
myTd = document.createElement('td');
myInput = document.createElement('input');
myInput.setAttribute('id','Des' + progr);
myInput.setAttribute('name','Descrizione' + progr);
myInput.setAttribute('value', document.getElementById('desArt').value);
myInput.setAttribute('class', 'form-control border-0');
myInput.setAttribute('style', 'background-color:transparent');
myInput.setAttribute('disabled', 'disabled');
myTd.appendChild(myInput);
myTr.appendChild(myTd);
myTd = document.createElement('td');
myInput = document.createElement('input');
myInput.setAttribute('id','Agg' + progr);
myInput.setAttribute('name','Aggiuntiva' + progr);
myInput.setAttribute('value', document.getElementById('aggArt').value);
myInput.setAttribute('class', 'form-control border-0');
myInput.setAttribute('style', 'background-color:transparent');
myInput.setAttribute('disabled', 'disabled');
myTd.appendChild(myInput);
myTr.appendChild(myTd);
myTd = document.createElement('td');
myInput = document.createElement('input');
myInput.setAttribute('id','Um' + progr);
myInput.setAttribute('name','Um' + progr);
myInput.setAttribute('value', document.getElementById('umArt').value);
myInput.setAttribute('class', 'form-control border-0');
myInput.setAttribute('style', 'background-color:transparent; width:40px');
myInput.setAttribute('disabled', 'disabled');
myTd.appendChild(myInput);
myTr.appendChild(myTd);
myTd = document.createElement('td');
myInput = document.createElement('input');
myInput.setAttribute('id','Qta' + progr);
myInput.setAttribute('name','Qta' + progr);
myInput.setAttribute('value', document.getElementById('qtaArt').value);
myInput.setAttribute('class', 'form-control border-0');
myInput.setAttribute('style', 'background-color:transparent; width:50px');
myInput.setAttribute('disabled', 'disabled');
myTd.appendChild(myInput);
myTr.appendChild(myTd);
tableart.appendChild(myTr);
progr++;
document.getElementById('proArt').value = progr;
此表是从 iframe 模态动态填充的。一切都很好,除非我将命令Request.Form["Nameoftheinput"]
与在 javascript 中创建的表的输入一起使用,它报告空值。该命令适用于页面的所有其他输入