1

I have two lists on my code, one of "id_product" other one of "name_product"

for (i in lista_prod) {
  const opt = document.createElement('option');
  for (j in lista_prodname) {

    opt.innerHTML = lista_prodname[j]
  }
  opt.value = lista_prod[i];
  selectprod.appendChild(opt)
}

I want to create something iterable that the first index of a list get together with the firt element of the other list and continue until the end

Nick Parsons
  • 45,728
  • 6
  • 46
  • 64
Eduardo Fellipe
  • 376
  • 2
  • 14
  • You can do something like [this](https://stackoverflow.com/a/12585370/3082296) or [this](https://stackoverflow.com/a/44645208/3082296) – adiga Nov 05 '19 at 11:56
  • `lista_prod.forEach((value , i) => { const opt = document.createElement('option'); opt.innerHTML =lista_prodname[i]; opt.value = value; selectprod.appendChild(opt) })` – adiga Nov 05 '19 at 11:59
  • Actually that was highly simple, i just use ` for (let i = 0; i < lista_prod.length; i++) { const opt = document.createElement('option'); opt.value = lista_prod[i]; opt.innerHTML = lista_prodname[i] selectprod.appendChild(opt) }` – Eduardo Fellipe Nov 05 '19 at 14:56
  • That would work too – adiga Nov 05 '19 at 14:58

0 Answers0