Foros del Web » Programando para Internet » Javascript » Frameworks JS »

consulta dom

Estas en el tema de consulta dom en el foro de Frameworks JS en Foros del Web. Tengo la siguiente tabla: Código: <div class="bottomLine"> <table id="tabla"> <tr> <th><label for="secundario">Título Secundario</label></th> <td><input type="text" name="secundario" id="secundario" value="<?=v('secundario')?>" /></td> <th><label for="institucion">Institución</label></th> <td><input type="text" name="institucion" id="institucion" ...
  #1 (permalink)  
Antiguo 25/06/2008, 08:13
 
Fecha de Ingreso: junio-2008
Mensajes: 110
Antigüedad: 15 años, 10 meses
Puntos: 0
consulta dom

Tengo la siguiente tabla:

Código:
        <div class="bottomLine">
			<table id="tabla">
              <tr>
                <th><label for="secundario">Título Secundario</label></th>
                <td><input type="text" name="secundario" id="secundario" value="<?=v('secundario')?>" /></td>
                <th><label for="institucion">Institución</label></th>
                <td><input type="text" name="institucion" id="institucion" value="<?=v('institucion')?>" /></td>
                </tr>
              <tr>
                <th><label for="universitario">Título Universitario</label></th>
                <td><input type="text" name="universitario" id="universitario" value="<?=v('universitario')?>" /></td>
                <th><label for="institucion2">Institución</label></th>
                <td><input type="text" name="institucion2" id="institucion2" value="<?=v('institucion2')?>" /></td>
              </tr>
              <tr>
                <th><label for="idiomas">Idiomas</label></th>
                <td><input type="text" name="idiomas" id="idiomas" value="<?=v('idiomas')?>" /></td>
                <th><label for="domIdioma">% de dominio</label></th>
                <td><input class="short" type="text" name="domIdioma" id="domIdioma" value="<?=v('domIdioma')?>" /> <a href="#" id="agregarId">[+] Agregar</a>
			  </tr>
			  <tr>
                <th><label for="sistemas">Manejo de sistemas</label></th>
                <td><input type="text" name="sistemas" id="sistemas" value="<?=v('sistemas')?>" /></td>
                <th><label for="domIdioma">% de dominio</label></th>
                <td><input class="short" type="text" name="domSistema" id="domSistema" value="<?=v('domSistema')?>" /> <a href="#" >[+] Agregar sistema</a></td>
              </tr>
              <tr>
                <th><label for="estudia">Estudia actualmente</label></th>
                <td><input class="short" name="estudia" type="radio" value="si" /><label for="si">Si</label> <input class="short" name="estudia" type="radio" value="no" /><label for="no">No</label></td>
                <th><label for="carrera">Carrera</label></th>
                <td><input type="text" name="carrera" id="carrera" value="<?=v('carrera')?>" /></td>
              </tr>
			<script type="text/javascript" src="menu.js">
				insertarIdioma();
			</script>
            </table>
        </div>
el siguiente javascript:

Código:
function insertarIdioma()
{
	document.getElementById('agregarId').onclick = function() {

	row = document.createElement('tr');
	head1 = document.createElement('th');
	label1 = document.createElement('label');
	
	head2 = document.createElement('th');
	label2 = document.createElement('label');	
	
	text1 = document.createTextNode("Idiomas");
	data1 = document.createElement('td');
	input1 = document.createElement('input');
	input1.setAttribute("name","idiomas");
	input1.setAttribute("type","text");
	
	text2 = document.createTextNode("% de dominio");
	data2 = document.createElement('td');
	input2 = document.createElement('input');
	input2.setAttribute("name","domIdioma");	
	input2.setAttribute("type","text");
	
	label1.appendChild(text1);
	head1.appendChild(label1);
	row.appendChild(head1);
	row.appendChild(data1);
		
	data1.appendChild(input1);
	
	label2.appendChild(text2);
	head2.appendChild(label2);
	row.appendChild(head2);
		
	data2.appendChild(input2);
		
	row.appendChild(data2);

	document.getElementById('tabla').appendChild(row);
	
	return false;
	}
}
No me funciona, la verdad que no puedo localizar que problema tiene. Me ayudan?
  #2 (permalink)  
Antiguo 28/06/2008, 10:26
Avatar de marcopoloaz06  
Fecha de Ingreso: julio-2007
Ubicación: México
Mensajes: 457
Antigüedad: 16 años, 9 meses
Puntos: 11
Respuesta: consulta dom

hola,
solo tienes
que ponerlo
en la funcion onload
Código HTML:
onload = function(){

	document.getElementById('agregarId').onclick = function() {

	row = document.createElement('tr');
	head1 = document.createElement('th');
	label1 = document.createElement('label');
	
	head2 = document.createElement('th');
	label2 = document.createElement('label');	
	
	text1 = document.createTextNode("Idiomas");
	data1 = document.createElement('td');
	input1 = document.createElement('input');
	input1.setAttribute("name","idiomas");
	input1.setAttribute("type","text");
	
	text2 = document.createTextNode("% de dominio");
	data2 = document.createElement('td');
	input2 = document.createElement('input');
	input2.setAttribute("name","domIdioma");	
	input2.setAttribute("type","text");
	
	label1.appendChild(text1);
	head1.appendChild(label1);
	row.appendChild(head1);
	row.appendChild(data1);
		
	data1.appendChild(input1);
	
	label2.appendChild(text2);
	head2.appendChild(label2);
	row.appendChild(head2);
		
	data2.appendChild(input2);
		
	row.appendChild(data2);

	document.getElementById('tabla').appendChild(row);
	
	return false;
	}
}
saludos...
:]
__________________
Aerolíneas Alicia :D
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:26.