-1

How to do autocreate variables(names,ssns and more), depending how many arguments we have in function, for each element i wanna have column(but i dont wanna to create it in manual mode) each column put in automatically created div, other column into second div. (i need to create table depending from xml tags, depending how many elements and tags it has)

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;
}
Druidman
  • 7
  • 5

1 Answers1

0

use the arguments variable:

function func() {
  for (var i = 0; i < arguments.length; i++) {
    console.log(arguments[i]);
  }
}
Aviran Cohen
  • 5,581
  • 4
  • 48
  • 75