Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/10/2011, 14:57
elrey123
 
Fecha de Ingreso: febrero-2009
Mensajes: 61
Antigüedad: 15 años, 2 meses
Puntos: 1
suma de selects

buenas a todos. tengo el siguiente codigo,
Código:
<html>
<head>
<title>Busqueda Cliente</title>
<body>
<DIV class="TabbedPanelsContentGroup">
 <p>&nbsp;</p>
<table width="88%" border="0" align="center">
  <tr>
    <th background="images/navi.jpg"><p class="Estilo1"><font size="+2"><p>&nbsp;</p>Busqueda del Cliente</font></p><br/>
     </th>
  </tr>
</table>
<?php
$buscar=$_POST['buscar'];
if (!isset($buscar)){
echo "Debe especificar una cadena a buscar";
echo "<p>Ejemplo: Kenneth Alexander</p> \n";

echo "</html></body> \n";
exit;
}
//conexion a la base de datos
$link = mysql_connect("localhost", "root", "matrix");
mysql_select_db("dados", $link);
$sql = "SELECT * FROM clientes WHERE Nombres LIKE '%$buscar%' ORDER BY Nombres";
$result = mysql_query($sql, $link);
if ($row = mysql_fetch_array($result)){
echo "<table border = '3' align=center bgcolor=#E6E8FA bodercolor=#545454> \n";
//Mostramos los nombres de las tablas
echo "<p>&nbsp;</p> \n";
echo "<tr><center>Los datos del cliente son:</center></tr> \n";
mysql_field_seek($result,0);
while ($field = mysql_fetch_field($result)){
echo "<td><b>$field->name</b></td> \n";
}
echo "</tr> \n";
do {
echo "<tr> \n";
echo "<td bgcolor=#8E2323><font color=white>".$row["id_cliente"]."</font></td> \n";
echo "<td bgcolor=#8E2323><font color=white>".$row["Nombres"]."</font></td> \n";
echo "<td bgcolor=#8E2323><font color=white>".$row["Apellidos"]."</font></td> \n";
echo "<td bgcolor=#8E2323><font color=white>".$row["Direccion"]."</font></td> \n";
echo "<td bgcolor=#8E2323><font color=white>".$row["Telefono"]."</font></td> \n";
echo "</tr> \n";
} while ($row = mysql_fetch_array($result));

echo "</table></center> \n";
}else{
echo "<p><center>¡No se ha encontrado ningún registro, por favor registra al cliente!</center></p>\n";
echo "<p><center><a href=principal.php>Ir a Registrar Clientes</center></p> \n";
}
?>
<p>&nbsp;</p>
<center><a href="variados.php"> VARIADOS </a></center>
<p>&nbsp;</p>
<table width="68%" border="0" align="center">
    <tr>
      <th>
	  
  <form id="form1" name="form1" method="post" action="operacion/guardarventa.php">
        <p><span class="Estilo1"><font color="#0066CC"><strong></strong></font></span><span class="Estilo2"><font color="#0066CC"><strong></strong></font></span><span class="Estilo1"><font color="#0066CC"><strong> </strong></font></span></p>
<table width="88%" cellspacing="5" cellpadding="0"  align="center" bordercolor="#545454" border="3><center>
<tr>
  <th class="menumain"> 
  <th bgcolor="#8E2323"><font color="white"><center>Clave</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Tama&ntilde;o</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Precio</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Nº. de Pizza</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Nº. de Tortas</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Precio tortas</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Extra</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Refresco</font></center></th>
  <th bgcolor="#8E2323"><font color="white"><center>Precio Refresco</font></center></th>  
  <th bgcolor="#8E2323"><font color="white"><center>Id_cliente</font></center></th> 
  <th bgcolor="#8E2323"><font color="white"><center>Fecha</font></center></th></label>
</tr>
<tr>
  
<th bgcolor="#E6E8FA"><label><select name="select" onchange="slctryole(this,this.form.select2)">
		<option>-Pizzas-</option>
		<option value="VE">VE</option>
		<option value="NA">NA</option>
	        <option value="HA">HA</option>
                <option value="PE">PE</option>        
                <option value="VG">VG</option>
                <option value="AT">AT</option>
                <option value="RO">RO</option>
                <option value="TO">TO</option>
                <option value="TQ">TQ</option>
                <option value="ME">ME</option>
                <option value="ES">ES</option>
                <option value="SU">SU</option>
                <option value="QB">QB</option>
                <option value="AP">AP</option>
        </select></label></th>
<th bgcolor="#E6E8FA"><label><select name="select2" onchange="slctryole(this,this.form.select3)">
		<option>- - - - - -</option>
	</select></label></th>
        <th bgcolor="#E6E8FA"><label><select name="select3">
		<option>0</option>
	</select></label></th>

<th bgcolor="#E6E8FA"><label><select name="cantidadpizza" id="cantidaddepizza" class="boot">
          <option value="--" checked>--</option>          
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          
</select></label></th>

<th bgcolor="#E6E8FA"><label><select name="numerodetortas" id="numerodetortas" class="boot">
          <option value="--" checked>--</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          
</select></label></th>
<th bgcolor="#E6E8FA"><label><select name="preciodetortas" id="preciodetortas" class="boot">
          <option value="------" checked>------</option>
          <option value="22">22</option>
</select></label></th>

<th bgcolor="#E6E8FA"><label><select name="extra" id="extra" class="boot">
          <option value="------" checked>------</option>
          <option value="7">7</option>
          <option value="12">12</option>
</select></label></th>

<th bgcolor="#E6E8FA"><label><select name="refrescos" OnChange="cambiar()">
<option value="Seleccionar" selected>Seleccionar</option>
<option value="Coca 600 ml" >Coca 500 ml</option>
<option value="Cristal 600 ml">Cristal 600 ml</option>
<option value="Coca Light 600 ml">Coca Light 600 ml</option>
<option value="Coca 1 Litro">Coca 1 Litro</option>
<option value="Coca 2 Litros">Coca 2 Litros</option>
<option value="Coca 2.500 Litros">Coca 2.500 Litros</option>
<option value="Coca 3 Litros">Coca 3 Litros</option>
</select></label></th>

<th bgcolor="#E6E8FA"><label><select name="preciorefresco">
<option value="0" selected>0</option>
</select></label></th>

<th bgcolor="#E6E8FA"><span id="sprytextfield1">
        <label><input name="id_cliente" class="boot" type="text" id="id_cliente" size="13" value=<?php echo $row['id_cliente'];?>></label><span class="textfieldRequiredMsg">Campo vacio</span></span>
</th>
<th bgcolor="#E6E8FA"><span id="sprytextfield2">
        <label><input name="fecha" class="boot" type="text" id="fecha" size="13" value=<?php echo date("Y/m/d");?>></label><span class="textfieldRequiredMsg">Campo vacio</span></span>
</th>
</table></center>
<p>&nbsp;</p>

<?php

//declaramos las variables
$cantidadpizza='$_POST[cantidadpizza]';
$preciopizza='$_POST[preciopizza]';
$numerodetortas='$_POST[numerodetortas]';
$preciodetortas='$_POST[preciodetortas]';
$extra='$_POST[extra]';
$preciototal="";

function SaveData($cantidadpizza,$preciopizza,$numerodetortas,$preciotortas,$extra){
  session_start(); 
 $_SESSION['varibles']=$cantidadpizza."-".$preciopizza."-".$numerodetortas."-".$preciodetortas."-".$extra;
 }  

if($cantidadpizza>0||$preciopizza>0||$numerodetortas>0||$preciodetortas>0||$extra>0){

SaveData($_POST['cantidadpizza'], $_POST['preciopizza'], $_POST['numerodetortas'], $_POST['preciodetortas'], $_POST['extra']);
$form = explode("-",$_SESSION['variables']);
list($cantidadpizza,$preciopizza,$numerodetortas,$preciodetortas,$extra) = $form;  
$multiplica1=($cantidadpizza*$preciopizza);
$multiplica2=($numerodetortas*$preciotortas);
$sumatotal=($multiplica1+$multiplica2+$extra);
$preciototal=$sumatotal;
echo "$preciototal";
}
?>
<p>&nbsp;</p>
<table width="30%" border="0" align="center"  class="down">
  
    <tr>
      <td width="38%" class="menumain">PRECIO DE LA VENTA:</td>
      <td width="67%"><span id="sprytextfield3">
        <label><input name="preciototal" class="boot" type="text" id="preciototal" size="15" value="<?php echo $preciototal; ?>"></label><span class="textfieldRequiredMsg">Campo vacio</span></span></td>
    </tr>
	
  </table>

<p>
         <input type="submit" class="boot" name="guarda" value="GUARDAR VENTA" />
         
       </p>
</form>
</body>
</html>
cabe aclarar que el precio de la pizza lo obtengo con select dependientes de 3 niveles qes una funcion con javascripts, lo mismo del precio del refresco con otra funcion de select dependientes.
lo que quiero hacer es que al seleccionar alguna de las opciones del select numerodetortas este se multiplique por el select de preciodetortas, depues hacer lo mismo con el select de numerodepizzas multiplicarlo con el select del preciopizza y posteriormente realizar la suma de estos, mas la suma del select de extra, mas la suma del select del preciorefresco y el resultado asignarlo a la caja de texto que se llama preciototal.

ojala me puedan orientar de como relizar esta operacion con los select. lo empece a realizar pero no funciona.

saludos..