Ver Mensaje Individual
  #6 (permalink)  
Antiguo 07/01/2006, 15:14
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
De acuerdo eso ya lo hice =)

Mira aca te dejo el codigo para que veas mas menos de lo que hablo...

Código HTML:
<FONT COLOR=000000 SIZE=4 FACE=Arial>
 Seleccione el número de articulos que son
</FONT>
<form action="<?=$_SERVER["PHP_SELF"]?>" method="get"> 
<select name="filas"> 
<? for($i=1; $i<=20; $i++){ 
echo "<option value='".$i."'>".$i."</option>";
}?> 
</select> 
<input type="hidden" name="crear" value="tabla"> 
<input type="submit" value="crear"> 
</form>

<table width="700" border="1" cellpadding=2 align="center" cellspacing=2><tr><td>
<form name="cotizacion" method="post" action="email.php" onSubmit="return chkcotizacion()">
 <input type="hidden" name="iva" value="1.19" id="iva">
 <table border="0" width=100% cellpadding=0 cellspacing=0>
  <tr>
   <td align=center colspan=2>
     <font face="Verdana, Arial, Helvetica, sans-serif" color="0099ff" size=3>
     <b>DESTINATARIO:</b><br><input type="text" name="email" size=25 value="EMAIL DESTINO"><br><br>
   </td>
  </tr>
  <tr>
   <td align=center colspan=2 width=100%>
     <table border=1 cellpadding=0 cellspacing=0 bordercolor=555555 width=680>
      <tr>
       <td align=center width=80>
        <font face="Arial, Helvetica, sans-serif" color="000000" size=3><b>CANT.</b></font>
       </td>
       <td align=center width=100>
        <font face="Arial, Helvetica, sans-serif" color="000000" size=3><b>ITEM</b></font>
       </td>
       <td align=center width=220>
        <font face="Arial, Helvetica, sans-serif" color="000000" size=3><b>ARTICULO</b></font>
       </td>
       <td align=center width=140>
        <font face="Arial, Helvetica, sans-serif" color="000000" size=3><b>V/UNIT.</b></font>
       </td>
       <td align=center width=140>
        <font face="Arial, Helvetica, sans-serif" color="000000" size=3><b>TOTAL</b></font>
       </td>
      </tr>
     </table>
<? 
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 = 'ARTICULO A-098';
      document.cotizacion['valor[$i]'].value = '7311'}
      break;
    case 'A-099': {
      document.cotizacion['articulo[$i]'].value = 'ARTICULO A-099';
      document.cotizacion['valor[$i]'].value = '8824'}
      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='ITEM' selected>ITEM</option>
          <option value='A-098'>A-098</option>
          <option value='A-099'>A-099</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>"; 
    } 
?>

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

SE GENERA UNA FILA DEPENDIEDO DEL USUARIO Y A SU VEZ EN ESA FILA SE GENERA ESTO

UN INPUT CON LA CANTIDAD
UN SELECT CON LOS ITEM
UN TEXTAREA QUE SE COMPLETA SOLO AL SELECCIONAR EL ITEM
UN INPUT DE VALOR QUE SE COMPLETA SOLO AL SELECCIONAR EL ITEM
UN INPUT DE TOTAL QUE MULTIPLICA LA CANTIDAD POR EL VALOR

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

Es por eso que a su vez se genera el script tantas veces como filas se creen (ahora puse 2 articulos pero son 1500) y debe ser asi ya que el select completa automaticamente los campos de ARTICULO y VALOR y si conservo solo un nombre completara solamente los de un select y no los demas ... 


Creo que ahi quedo mejor planteado 

Muchas Gracias.-
Pablo Araya.-




__________________
Adios ...!!!!