Ver Mensaje Individual
  #7 (permalink)  
Antiguo 09/03/2010, 11:07
kadet
 
Fecha de Ingreso: febrero-2008
Mensajes: 120
Antigüedad: 17 años, 1 mes
Puntos: 1
Respuesta: Problemas para pasar variable javascript a input

Cita:
Iniciado por warbandit69 Ver Mensaje
Ya lo logre amigo, gracias por tu ayuda, coloco el codigo para que aprecien los cambios que hice:

Código:
var num=0;
// Funcion para crear lineas de objetos
function crear(obj) {
  num++;
  fi = document.getElementById('fiel'); // 1
  contenedor = document.createElement('div'); // 2
  contenedor.id = 'div'+num; // 3
  fi.appendChild(contenedor); // 4
  
  ele = document.createElement('input'); // 5
  ele.type = 'text'; // 6
  ele.name = 'cantidad'+num; // 6
  ele.id = 'cantidad'+num; // 6
  ele.className = "cantidades";
  contenedor.appendChild(ele); // 7
  
  ele = document.createElement('input'); // 5
  ele.type = 'text'; // 6
  ele.name = 'material'+num; // 6
  ele.id = 'material'+num; // 6
  ele.className = "materiales";
  contenedor.appendChild(ele); // 7
  
  ele = document.createElement('input'); // 5
  ele.type = 'text'; // 6
  ele.name = 'nota'+num; // 6
  ele.id = 'nota'+num; // 6
  ele.className = "notasentrega";
  contenedor.appendChild(ele); // 7
  
  ele = document.createElement('input'); // 5
  ele.type = 'button'; // 6
  ele.value = '-'; // 8
  ele.name = 'div'+num; // 8
  ele.onclick = function () {borrar(this.name)} // 9
  contenedor.appendChild(ele); // 7
  //alert(num);
  var elemento = document.getElementById('camposmateriales');
  elemento.value= num; 
}

function borrar(obj) {
  fi = document.getElementById('fiel'); // 1 
  fi.removeChild(document.getElementById(obj)); // 10
  num=num-1;
  //alert(num);
  var elemento = document.getElementById('camposmateriales');
  elemento.value= num; 
}



Estoy intentando hacer lo mismo con un <select y me lo coloca, el problema está en como poner los options, se te ocurre alguna cosa? Gracias