如何自动创建变量(名称、ssns 等),取决于我们在函数中有多少个参数,对于我想要列的每个元素(但我不想在手动模式下创建它)每列放入自动创建的 div,其他列到第二个 div。(我需要根据 xml 标签创建表,具体取决于它有多少元素和标签)
function GetTableResult(checkername, position //(can be much more//) {
var xmlResponse = xmlHttp.responseXML;
root = xmlResponse.documentElement;
names = root.getElementsByTagName(checkername); //need to autocreate
ssns = root.getElementsByTagName(position);
var stuff = "";
for(var i=0; i<names.length; i++) {
stuff += names.item(i).firstChild.data + "<br/>";
}
var position = "";
for(var j=0; j<ssns.length; j++) {
position += ssns.item(j).firstChild.data + "<br/>";
}
theD = document.getElementById("theD");
theD.innerHTML = stuff;
theB = document.getElementById("theB");
theB.innerHTML = position;
}