Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/01/2006, 06:59
Avatar de BLAH !!
BLAH !!
 
Fecha de Ingreso: septiembre-2003
Ubicación: Región Metropolitana, Santiago, Chile
Mensajes: 706
Antigüedad: 20 años, 7 meses
Puntos: 16
Pregunta problema al envío de variables ...

mmm... por problemas de un JS tuve que cambiar el nombre de unos input. Pero ahora cuando envío el formulario no me aparece nada... no toma esos valores (obviamente tambien los cambie en el php de envío). El problema está en que como son inputs dinámicos (ya que se crean de acuerdo a las necesidades del cliente) deben nombrarse "NAME[$i]" lo unico que consegui para que el JS funcionara fue cambiarlos a "NAME$i" y todo funciona en el formulario pero al envío muere.

Así esta el codigo del formulario:

Código HTML:
<? 
if(isset($_GET["crear"])){ 
    echo '<table border="0" cellpadding="0" cellspacing="0" width="680">'; 
   for($i=1; $i<=$_GET["filas"]; $i++){ 
        echo "
<script>
function cambio$i( ITEM ) {
  switch ( ITEM )  {
    case 'A-098': {
      document.cotizacion.articulo$i.value = 'Respuesta 1';
      document.cotizacion.valor$i.value = '1'}
      break;
    case 'A-099': {
      document.cotizacion.articulo$i.value = 'Respuesta 2';
      document.cotizacion.valor$i.value = '2'}
      break;
    case 'A-100': {
      document.cotizacion.articulo$i.value = 'Respuesta 3';
      document.cotizacion.valor$i.value = '3'}
      break;
  }
}
</script>
      <tr> 
       <td align=center width=80><input type=text name=cantidad[$i] id=cantidad[$i] size=5></td> 
       <td align=center width=100>
        <select type=text name=item[$i] id=item[$i] onChange='cambio$i(this.value)'>
	 <option value='0' selected>ITEM</option>
         <option value='A-098'>A-098</option>
         <option value='A-099'>A-099</option>
         <option value='A-100'>A-100</option>
        </select></td> 
       <td align=center width=220><textarea cols=22 rows=2 name=articulo$i id=articulo$i></textarea></td> 
       <td align=center width=140>$ <input type=text name=valor$i id=valor$i size=10 onKeyUp=\"javascript: document.getElementById('total[$i]').value = document.getElementById('valor$i').value * document.getElementById('cantidad[$i]').value;\" onMouseMove=\"javascript: document.getElementById('total[$i]').value = document.getElementById('valor$i').value * document.getElementById('cantidad[$i]').value;\"></td> 
       <td align=center width=140>$ <input type=text name=total[$i] id=total[$i] size=10></td> 
      </tr>"; 
    } 
    echo "</table>"; 
} 
?> 

-------------------------------------------------------------------------

Y así está el código del ENVÍO:

Código HTML:
 <table border=1 bordercolor=111111 cellpadding=2 cellspacing=0 width=680>";

$i=1; 
$totaltotal= 0; 
foreach($_POST["cantidad"] as $cantidad){ 
    $total = $_POST["total"][$i]; 
    $totaltotal = $totaltotal+$total;
    $iva1 = $totaltotal*$iva;
    $iva2 = $iva1-$totaltotal;
    $bruto = $totaltotal+$iva2;
    $cuerpo .="<tr> 
       <td align=center width=80>
        <font face='Arial, Helvetica, sans-serif' color='000000' size=3>
         ".$_POST["cantidad"][$i]."
        </font>
       </td> 
       <td align=center width=100>
        <font face='Arial, Helvetica, sans-serif' color='000000' size=3>
         ".$_POST["item"][$i]."
        </font>
       </td> 
       <td align=center width=220>
        <p align=left><font face='Arial, Helvetica, sans-serif' color='000000' size=2>
         ".$_POST["articulo"][$i]."
        </font></p>
       </td> 
       <td align=right width=140>
        <font face='Arial, Helvetica, sans-serif' color='000000' size=3>
         $ ".$_POST["valor"][$i]."
        </font>
       </td> 
       <td align=right width=140>
        <font face='Arial, Helvetica, sans-serif' color='000000' size=3>
         $ ".$total."
        </font>
       </td>
      </tr>"; 
    $i++; 
} 
$cuerpo .= "</table> 
--------------------------------------------------------------------------

He intentado cambiar en el envío
esto : ".$_POST["valor"][$i]." por esto : ".$_POST["valor"]$i." y también por esto : ".$_POST["valor$i"]."

Pero ninguna me funciono ....
No se de que otra forma hacerlo...
__________________
Adios ...!!!!