Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/09/2010, 07:15
Avatar de repara2
repara2
 
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 8 meses
Puntos: 331
Respuesta: Update de campos dinamicos

Hola Vuuguma, los campos de un formulario de identifican por el atributo name.
Si envias un form y haces print_r($_POST); verás cómo te llega la información del formulario. Parece que esto ya lo controlas porque tienes todos tus campos con name.
El problema es que en este código, en las siguienes vueltas del bucle nombrará a los campos con los mismos nombre y así pierdes valores. PUedes arreglarlo con un contador tipo:

Código PHP:
<?php
 
    $x 
0//COntador de vueltas
    
do {     
    
?>
    <tr>
    <td><input name="<?=$x?>_txt_desde" type="text" id="txt_desde" tabindex="7" onKeyUp="this.value=formateafecha(this.value);" value="<?php echo  implode'/'array_reverseexplode'-'$row_grid['desde'] ) ) ); ?>"></td>
    <td><input name="<?=$x?>_txt_hasta" type="text" id="txt_hasta" tabindex="8" onKeyUp="this.value=formateafecha(this.value);" value="<?php echo  implode'/'array_reverseexplode'-'$row_grid['hasta'] ) ) ); ?>"></td>
    
    <td width="50"><select name="<?=$x?>_cbo_reg" class="cbo_ancho100" id="cbo_reg" tabindex="10">
      <option value="1" selected <?php if (!(strcmp(1$row_grid['reg']))) {echo "selected=\"selected\"";} ?>>SA</option>
      <option value="2" <?php if (!(strcmp(2$row_grid['reg']))) {echo "selected=\"selected\"";} ?>>HD</option>
      <option value="3" <?php if (!(strcmp(3$row_grid['reg']))) {echo "selected=\"selected\"";} ?>>MP</option>
<option value="4" <?php if (!(strcmp(4$row_grid['reg']))) {echo "selected=\"selected\"";} ?>>PC</option>
    </select></td>
    <td><input name="<?=$x?>_txt_importe" type="text" id="txt_importe" tabindex="11" onKeyUp="revisaCadena(this)" value="<?php echo $row_grid['importe']; ?>" size="15"></td>
    <td width="28" align="center"><input <?php if (!(strcmp($row_grid['ck_L'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="<?=$x?>_ck_L" id="ck_L" tabindex="12"></td>
    <td width="28" align="center"><input <?php if (!(strcmp($row_grid['ck_M'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="<?=$x?>_ck_M" id="ck_M" tabindex="13"></td>
    <td width="28" align="center"><input <?php if (!(strcmp($row_grid['ck_X'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="<?=$x?>_ck_X" id="ck_X" tabindex="14"></td>
    <td width="28" align="center"><input <?php if (!(strcmp($row_grid['ck_J'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="<?=$x?>_ck_J" id="ck_J" tabindex="15"></td>
    <td width="28" align="center"><input <?php if (!(strcmp($row_grid['ck_V'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="<?=$x?>_ck_V" id="ck_V" tabindex="16"></td>
    <td width="28" align="center"><input <?php if (!(strcmp($row_grid['ck_S'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="<?=$x?>_ck_S" id="ck_S" tabindex="17"></td>
    <td width="32" align="center"><input <?php if (!(strcmp($row_grid['ck_D'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="<?=$x?>_ck_D" id="ck_D" tabindex="18">
      <input name="<?=$x?>_id_tar_grid" type="hidden" id="id_tar_grid" value="<?php echo $row_grid['id_tarifa_grid']; ?>" size="2"></td>
  </tr>
  <?php } while ($row_grid mysql_fetch_assoc($grid));{
  
//lo que sea
  
$x ++;
  } 
?>
A ver si sirve, salu2