Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/11/2008, 14:09
vmac179
 
Fecha de Ingreso: julio-2007
Ubicación: /home/victor
Mensajes: 114
Antigüedad: 17 años, 7 meses
Puntos: 0
Validar tabla dinamica

Espero me puedan ayudar
Código PHP:
function agregar_fila(origen,destino) {
    
///////////////////////////////////////////

    
var region   origen.regiones.value;
    var 
territorio origen.territorio.value;
    var 
provincia origen.provincia.value;
    var 
comuna origen.comuna.value;
    var 
localidad origen.value;
    
    var 
nuevo_indice destino.rows.length;

    var 
fila;
    var 
celda;
    var 
valor;
    
    
fila destino.insertRow(nuevo_indice);
    
fila.style.background "white";
    
    
///////////////////////////////////////////

    
celda fila.insertCell(0);
    
valor document.createElement("input");
        
valor.type "checkbox";
        
valor.id "marca[]";
        
valor.name "marca[]";
        
valor.value nuevo_indice;
    
celda.appendChild(valor);

    
///////////////////////////////////////////

    
celda fila.insertCell(1);
    var 
region document.createElement('input'
        
region.type 'hidden'

    
var region_id document.getElementById('regiones');
        var 
txtTextObj document.getElementById('txtText');
        
    var 
selIndex region_id.selectedIndex;
        
region.value region_id.options[selIndex].text;    

    
valor document.createTextNode(region.value);
    
celda.appendChild(valor);
    
    
///////////////////////////////////////////

    
celda fila.insertCell(2);
    var 
territorio document.createElement('input'
        
territorio.type 'hidden'

    
var territorio_id document.getElementById('territorio');
        var 
txtTextObj document.getElementById('txtText');

    var 
selIndex territorio_id.selectedIndex;
        
territorio.value territorio_id.options[selIndex].text;    

    
valor document.createTextNode(territorio.value);
    
celda.appendChild(valor);
    
    
///////////////////////////////////////////

    
celda fila.insertCell(3);
    var 
provincia document.createElement('input'
        
provincia.type 'hidden'

    
var provincia_id document.getElementById('provincia');
        var 
txtTextObj document.getElementById('txtText');

    var 
selIndex provincia_id.selectedIndex;
        
provincia.value provincia_id.options[selIndex].text;    

    
valor document.createTextNode(provincia.value);
    
celda.appendChild(valor);
    
    
///////////////////////////////////////////

    
celda fila.insertCell(4);
    var 
comuna document.createElement('input'
        
comuna.type 'hidden'

    
var comuna_id document.getElementById('comuna');
        var 
txtTextObj document.getElementById('txtText');


    var 
selIndex comuna_id.selectedIndex;
        
comuna.value comuna_id.options[selIndex].text;

    
valor document.createTextNode(comuna.value);
    
celda.appendChild(valor);

    
///////////////////////////////////////////

    
celda fila.insertCell(5);

    var 
localidad document.createElement('input')
        
localidad.type 'hidden'
        
localidad.name 'localidad[]'

    
var localidad_id document.getElementById('localidad');
        var 
txtTextObj document.getElementById('txtText');

    var 
selIndex localidad_id.selectedIndex;
        
localidad.value localidad_id.options[selIndex].text;

    
valor document.createTextNode(localidad.value);
    
celda.appendChild(valor);

    
///////////////////////////////////////////

    
celda fila.insertCell(6);

    var 
localidad_value document.getElementById('localidad');
    var 
selIndex localidad_value.selectedIndex;
    var 
val localidad_value.options[selIndex].value;
    
valores val.split(',')

    var 
latitud document.createElement('input'// latitud
        
latitud.type 'text'
        
latitud.name 'latitud[]'
        
latitud.id 'latitud'
        
latitud.onblur coordenadas_1;
        
latitud.onkeypress numeros_dom;
        
latitud.value valores[1]
        if (
valores[1] != '') {
        
latitud.readOnly true
        
}

        
celda.appendChild(latitud);

    
///////////////////////////////////////////

    
celda fila.insertCell(7);

    var 
localidad_value document.getElementById('localidad');
    var 
selIndex localidad_value.selectedIndex;
    var 
val localidad_value.options[selIndex].value;
    
valores val.split(',')

    var 
longitud document.createElement('input'// longitud
        
longitud.type 'text'
        
longitud.name 'longitud[]'
        
longitud.id 'longitud'
        
longitud.onkeypress numeros_dom;
        
longitud.value valores[2]
        if (
valores[2] != '') {
        
longitud.readOnly true
        
}

        
celda.appendChild(longitud);

    
///////////////////////////////////////////

    
celda fila.insertCell(8);
    var 
monto document.createElement('input'// montos
        
monto.type 'text'
        
monto.name 'montos[]'
        
monto.setAttribute('class''required')
        
monto.title 'Ingrese el monto asignado'
        
monto.onkeypress numeros_dom;

        
celda.appendChild(monto);

    
///////////////////////////////////////////

    
var    region document.createElement('input'// regiones
        
region.type 'hidden'
        
region.name 'regiones[]'

    
var region_id document.getElementById('regiones');
        var 
txtidObj document.getElementById('txtid');

    var 
selIndex region_id.selectedIndex;
        
region.value region_id.options[selIndex].id;

        
celda.appendChild(region);

    
///////////////////////////////////////////

    
var    territorio document.createElement('input'// territorio
        
territorio.type 'hidden'
        
territorio.name 'territorios[]'

    
var territorio_id document.getElementById('territorio');
        var 
txtidObj document.getElementById('txtid');

    var 
selIndex territorio_id.selectedIndex;
        
territorio.value territorio_id.options[selIndex].id;

        
celda.appendChild(territorio);

    
///////////////////////////////////////////

    
var    provincia document.createElement('input'// territorio
        
provincia.type 'hidden'
        
provincia.name 'provincias[]'

    
var provincia_id document.getElementById('provincia');
        var 
txtidObj document.getElementById('txtid');

    var 
selIndex provincia_id.selectedIndex;
        
provincia.value provincia_id.options[selIndex].id;

        
celda.appendChild(provincia);

    
///////////////////////////////////////////

    
var    comuna document.createElement('input'// territorio
        
comuna.type 'hidden'
        
comuna.name 'comunas[]'

    
var comuna_id document.getElementById('comuna');
        var 
txtidObj document.getElementById('txtid');

    var 
selIndex comuna_id.selectedIndex;
        
comuna.value comuna_id.options[selIndex].id;

        
celda.appendChild(comuna);

    
///////////////////////////////////////////

    
var localidad_value document.getElementById('localidad');
    var 
selIndex localidad_value.selectedIndex;
    var 
val localidad_value.options[selIndex].value;
    
valores val.split(',')

    var 
localidad document.createElement('input')
        
localidad.type 'hidden'
        
localidad.name 'localidades[]'
        
localidad.value valores[0]

        
celda.appendChild(localidad);


Código PHP:
function coordenadas_1() {

inputed=document.getElementById('latitud["+marca[]+"]');
a=inputed.value;
alert(a);

Código PHP:
 <button type="button" name="boton" id="boton" onClick="agregar_fila(form,info)" disabled=true >Agregar</button>
  <
button type="button" onClick="remover_filas_marcadas(info)">Remover</button>

<
table class="ensayo" id="info" name="info">
<
tr class="titulos">
    <
td>&nbsp;</td>
    <
td>Region</td>
    <
td>Territorio</td>
    <
td>Provincia</td>
    <
td>Comuna</td>
    <
td>Localidad</td>
    <
td>Latitud</td>
    <
td>Longitud</td>
    <
td>Monto</td>
</
tr>
</
table
Salu2