Ver Mensaje Individual
  #8 (permalink)  
Antiguo 06/01/2009, 13:52
yanwalt
 
Fecha de Ingreso: enero-2009
Mensajes: 1
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Añadir campos dinámicamente

NECESITOO AYUDAAAAAAAAAAA

estoy desarrollando una aplicacion con php javascript
en ella tengo un campo ke se llama cantidad de titulos....si yo ingreso 4 ps se crean dinamicamente 4 campos en este caso son llamados en el javascript n_titulos
ahora ke tnego creado los campos necesito sacar el valor de cada unopara guardarlo en la db pero como son creados dentro de un for y de forma dinamica no se como obtener dichos valores....
para mas ilustracion aca esta el codigo de la funcion en javascript ke me crea los campos dinamcios....
function cantidadTiposRecursosCrear()
{

alert("Datos Documento Almacenados");


var n_titulos = $('txt_cantidad').value;
var nr;
var html_str = '<table align="center">';
html_str +='<br>';
html_str +='<br>';
html_str +='<br>';

html_str +='<td colspan="5"><strong>CANTIDAD DE RECURSOS PARA INGRESAR</strong></td>';
html_str +='<br>';
html_str +='<br>';
var arreglo = new Array(n_titulos)

for(var i=0; i<n_titulos; i++)
{
html_str +='<table align="center">';
html_str +='<thead>';
html_str +='<tr>';

html_str +='</tr>';
html_str +='</thead>';
html_str +='</thead>';
html_str +='<br>';
html_str += '<tr><td><b>Tipos de Recursos'+(i+1)+':</b>&nbsp;</td>'+
'<td>&nbsp;&nbsp;<select id="txttipoRecurso_'+i+'" name="txttipoRecurso_'+i+'"notvalidzero="true" required="true" visiblename="Tipo de Recurso"'+(i+1)+'"/><td></tr>';
html_str +='<br>';


html_str += '<tr><td><b>Recursos'+(i+1)+':</b>&nbsp;</td>'+
'<td>&nbsp;&nbsp;<select id="txtRecurso_'+i+'" name="txtRecurso_'+i+'"notvalidzero="true" required="true" visiblename="Recurso"'+(i+1)+'"/><td></tr>';
html_str +='<br>';


html_str += '<tr><td><b>Número de Unidades'+(i+1)+':</b>&nbsp;</td>'+
'<td>&nbsp;&nbsp;<input type="text" id="txtNumeroUnidades_'+i+'" name="txtNumeroUnidades_'+i+'" required="true" visibleName="Unidades'+(i+1)+'"/><td></tr>';
html_str +='<br>';
html_str +='<br>';




var seleccion_tipo_recurso = document.createElement('select');
seleccion_tipo_recurso.name = 'txttipoRecurso_'+i;
seleccion_tipo_recurso.id = 'txttipoRecurso_'+i;
x_obtenerTipoRecurso('txttipoRecurso_'+i,$('txt_ca ntidad').value, actualizarTipo_Recurso);

var seleccion_recurso = document.createElement('select');
seleccion_recurso.name = 'txtRecurso_'+i;
seleccion_recurso.id = 'txtRecurso_'+i;

x_obtenerRecurso('txtRecurso_'+i,$('txt_cantidad') .value, actualizar_Recurso);

var ingresar_cantidad_recurso= document.createElement('select');
ingresar_cantidad_recurso.name = 'txtNumeroUnidades_'+i;
ingresar_cantidad_recurso.id = 'txtNumeroUnidades_'+i;









}
html_str += '<tr><td><input type="button" name="GuardarRecursoCompleto" id="GuardarRecursoCompleto" value="Agregar" class="boton">';
html_str += '</table>';

$('titulosMaterialDiferente').innerHTML = html_str;


for (i=0;i<arreglo.length;i++)
{
// alert (arreglo[i]);
}

//$('GuardarRecursoCompleto').onclick = GuardarAdquisicionRecursoXRecurso();



Element.showAs('block','titulosMaterialDiferente') ;

//GuardarAdquisicionRecursoXRecurso(n_titulos);
}