我想删除已输入数组的对象

时间:2016-05-23 05:19:47

标签: javascript html

var employees = [];

function add() {
  a = {
    tr: document.getElementById("trans").value,
    namex: document.getElementById("name").value,
    pd: document.getElementById("pd").value,
    age: document.getElementById("age").value,
    income: document.getElementById("income").value
  };
  employees.push(a.tr + "" + a.namex + "" + a.pd + "" + a.age + "" + a.income + "");
}

function show() {
  q = "";
  q = q + "";
  q = q + "Transaction NumberNameCivil StatusAgeIncome";
  q = q + "";
  q = q + "";
  b = -1;
  while (b < (employees.length - 1)) {
    b = b + 1;
    q = q + "";
    q = q + "" + employees[b] + "";
    q = q + "";
  }
  q = q + "";
  document.getElementById("qqq").innerHTML = q;
}

function del() {
  for (i = 0; i <= a.length; i++) {
    e = employees[0];
    f = employees[1];
    g = employees[2];
    h = employees[3];
    k = employees[4];
    if (e[i] == document.getElementById("trans").value) {
      e.splice(i, 1);
      f.splice(i, 1);
      g.splice(i, 1);
      h.splice(i, 1);
      k.splice(i, 1);
    }
  }
}

0 个答案:

没有答案