Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/08/2008, 08:58
art33
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 18 años, 1 mes
Puntos: 4
desactivar campos?

bueno esta es mi tabla...
Código HTML:
<form name="fvalida">
<table summary="Meeting Results" width="75%" height="2%" border="0" cellpadding="0" cellspacing="0" bordercolor="#B1C3D9" align="center">
<tbody id="lineaPedido" class="fondo" align="center">    	
  <tr>
    <td height="18" colspan="9" align="center" background="images/bg.JPG" bgcolor="#E0E0E0" scope="col"><font color="#996600" font face="Verdana, Arial, Helvetica, sans-serif" size="2">Pedidos</font></td>
  </tr>
 
 <tr>
    <th height="18" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">#</span></th>
    <th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7" style="text-align:center">PRODUCTO</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">UDM</span></th>
    <th align="center" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">DESCRIPCION</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">EXISTENCIA</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">ZONA</span></th>
    <th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">PRECIO</span></th>
    <th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">CANTIDAD</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">IMPORTE</span></th>
 </tr>  
 <tr>
<!-- 	En ajax.js de la funcion añadir existe una lista que debe contener todos los campos de esta tabla 
 --> <th width="20" height="14" background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col" id="lineaPedido2"><span class="Estilo4 Estilo5 Estilo6">1</span></th>
<th width="50" height="14" background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col"><input type="text" id="Item" class="input" style="width:57px; height:14px; border-width:0px"  onblur="RecuperaDescripcion(this.id,this.value,'Itemno','Uomcode Description','datos_articulo');valida_envia()" maxlength="7"/></th>
    <th background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col" width="70"><div id="datos_udm" style="font-size:14px"></div></th>
    <td  width="340" align="center" background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col"><div id="datos_articulo" class="Estilo3" style="font-size:10px; font-weight: bold"></div></td>
    <th background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col" width="100"><div id="datos_ext1" style="font-size:14px"></div></th>
    <th background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col" width="60"><div id="datos_zon1" style="font-size:14px"></div></th>
    <td width="70" height="14" valign="middle" background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col">
      <div align="left"><div class="Estilo3" style="font-size:12px">$
          <input type="text" id="precio" class="input" style="width:50px; height:14px; text-align:center;border-width:0px" maxlength="15"/>
      </div></div></td>
    <th width="50" height="14" background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col"><input type="text" id="cantidad" class="input"  style="width:50px; height:14px; text-align:center;border-width:0px"  onblur="calculaPrecio(document.getElementById('precio').value,this.value); anadir(); document.getElementById('Item').value='';" onKeyDown="return tab_btn(event);" maxlength="7"/></th>
    <th background="images/tdbg.jpg" bgcolor="#E0E0E0" scope="col" width="57"><span id="importe" class="Estilo3" style="font-size:11px;">&nbsp;</span></th>
  </tr>
</tbody>
</table>
</form> 
y este es mi script

Código PHP:
function anadir() {         
    if (
i <9){
    
//validar "Item"
    
if (document.fvalida.Item.value.length==0){
       
document.fvalida.Item.focus()
       return 
0;
    }
        var 
table = document.getElementById('lineaPedido');
        var 
row = table.insertRow(-1);
        var 
cell, text;
        var 
j;
        
// En la pagina pedido.html debe haber una fila con los campos de la lista inferior
        
campos = new Array("miCol0","Item","datos_udm","datos_articulo","datos_ext1","datos_zon1","precio","cantidad","importe");
        
tipo_campos = new Array("imagen","value","innerHTML","innerHTML","innerHTML","innerHTML","value","value","innerHTML");
        for (
j=0; j<9; j++) {        
            
cell = row.insertCell(-1);
            
cell.setAttribute("id","miCol"+ j);            
            switch(
tipo_campos[j]){
                case 
"value":
                
cell.innerHTML = document.getElementById(campos[j]).value;            
                break;
                case 
"innerHTML":
                
cell.innerHTML = document.getElementById(campos[j]).innerHTML;            
                break;
                case 
"imagen":
                
cell.innerHTML="<img src=\"images/x.png\" onclick=\"eliminaFila(this)\">";            
                break;        
            }
            
        }
        
i++;
    }  
    else {
        
alert("Solo se permite capturar " + i + " articulos por pedido");
    }
} 
funciona perfecto, sino hay nada capturado en el id "Item" no agrega la linea, pero si agrega la linea si es un dato invalido,

cuando es un dato invalido me agrega la sig, linea en php
Código PHP:
<?php
          
if (mysql_num_rows($item) != 0) {
              do {
                
$alinea = explode(" ", $Description );
                
$iElementos = count($alinea);        
                
$iElemento = 0;                
                do {                    
                    echo 
$row_item[$alinea[$iElemento]];
                    
$iElemento++;
                } while (
$iElemento < $iElementos);    
              } while (
$row_item = mysql_fetch_assoc($item));
          } else {
              echo 
"<div style=\"background-color: #FDD9D7;width:98%;width:98%;height:100%\" ><strong>" . $Tabla . "</strong> NO VALIDO</div>";
          }
           
?>
ya me bloquee, no se que hacer, alguna idea? sino me explique bien pregunten.
GRACIAS!!!

Última edición por art33; 25/08/2008 a las 09:07