Foros del Web » Programando para Internet » Javascript »

sumar

Estas en el tema de sumar en el foro de Javascript en Foros del Web. Código PHP: < SCRIPT LANGUAGE = "JavaScript" >          function  alterError ( value ) {         if ( value <= 0.99 ) {              newPounds  =  '0' ;         } else {              ...
  #1 (permalink)  
Antiguo 11/12/2003, 22:13
 
Fecha de Ingreso: agosto-2003
Ubicación: Mexico Df abajo del puente de municipio
Mensajes: 216
Antigüedad: 20 años, 8 meses
Puntos: 0
Mensaje sumar

Código PHP:
<SCRIPT LANGUAGE="JavaScript">
    
    function 
alterError(value) {
        if (
value<=0.99) {
            
newPounds '0';
        } else {
            
newPounds parseInt(value);
        }
        
newPence parseInt((value+.0008 newPounds)* 100);
        if (eval(
newPence) <= 9newPence='0'+newPence;
        
newString newPounds '.' newPence;
        return (
newString);
    }
    function 
showItems() {
        
index document.cookie.indexOf("TheBasket");
        
countbegin = (document.cookie.indexOf("="index) + 1);
            
countend document.cookie.indexOf(";"index);
            if (
countend == -1) {
                    
countend document.cookie.length;
            }
        
fulllist document.cookie.substring(countbegincountend);
        
totprice 0;
        
document.writeln('<form><table border=\"1\" cellspacing=\"0\" width=\"612\" bordercolor=\"#ff6600\" class=\"td\">');

document.writeln('<TR><TD width="250"><b>Producto</b></TD><TD width="80" align="right"><b>Cantidad</b></TD><TD width="120" align="right"><b>Costo x unidad</b></TD><td width="100" align="right"><b>Costo total</b><TD width="90">&nbsp;</TD></TR>');
        
itemlist 0;
        for (var 
0<= fulllist.lengthi++) {
            if (
fulllist.substring(i,i+1) == '[') {
                
itemstart i+1;
            } else if (
fulllist.substring(i,i+1) == ']') {
                
itemend i;
                
thequantity fulllist.substring(itemstartitemend);
                
itemtotal 0;
                
itemtotal = (eval(theprice*thequantity));
                
temptotal itemtotal 100;
                var 
tax itemtotal 100 * (0);
                    
tax Math.floor(tax 100)/100
                totprice 
totprice itemtotal tax;
                
itemlist=itemlist+1;
document.writeln('<tr><td>'+theitem+'</td><td align=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td align=right>'+alterError(itemtotal)+'</td><td align=center><input TYPE="button" NAME="remove" VALUE="Quitar" onclick="javascript:removeItem('+itemlist+')"></td></tr>');
            } else if (
fulllist.substring(i,i+1) == ',') {
                
theitem fulllist.substring(itemstarti);
                
itemstart i+1;
            } else if (
fulllist.substring(i,i+1) == '#') {
                
theprice fulllist.substring(itemstarti);
                
itemstart i+1;
            }
        }

        

        
document.writeln('<tr><td><b>Total</b></td><td align="right">p</td><td align=right>'+alterError(totprice)+'</td><td>&nbsp;</td></tr>');
        
document.writeln('</TABLE>');
    }

    function 
removeItem(itemno) {
        
newItemList null;
        
itemlist 0;
        for (var 
0<= fulllist.lengthi++) {
            if (
fulllist.substring(i,i+1) == '[') {
                
itemstart i+1;
            } else if (
fulllist.substring(i,i+1) == ']') {
                
itemend i;
                
theitem fulllist.substring(itemstartitemend);
                
itemlist=itemlist+1;
                if (
itemlist != itemno) {
                    
newItemList newItemList+'['+fulllist.substring(itemstartitemend)+']';
                }
            }
        }
        
index document.cookie.indexOf("TheBasket");
        
document.cookie="TheBasket="+newItemList;
        
top.location "estado.php";
    }

    function 
clearBasket() {
        if (
confirm('¿Confirma que desea quitar todos los productos del carrito?')) {
            
index document.cookie.indexOf("TheBasket");
            
document.cookie="TheBasket=.";
            
top.location "estado.php";
        }
    }
</SCRIPT>
<body bgcolor="#ffffff" bgproperties="fixed" background="estructura/imagenes/atras.gif" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" text="#000000" link="#000000" alink="#000000" vlink="#000000">

<table border="0" cellpadding="0" cellspacing="0" width="780" bgcolor="#FF6600">
  <tr>
    <td width="100%" valign="middle">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="50%">
    <a href="http://www.zumorecords.com">
    <img border="0" src="../imagenes/logo.gif">

    </a>

        </td>
        <td width="50%" valign="middle"><FORM ACTION="index.php">
      <p align="right">
      <INPUT NAME="palabra" size="15">
      <INPUT TYPE="submit" NAME="Buscar" value="Buscar"><br>
      <a class="codetres" href="../buscar.php"><font color="#FFFFFF"><b>Búsqueda avanzada</b></font></a></p>
    </form></td>
      </tr>
    </table>

    </td>
  </tr>
</table>

<table border="1" cellpadding="5" cellspacing="0" width="780" style="border-collapse: collapse" bgcolor="#FF6600">
  <tr> 
    <td align="left" valign="top">     
    <table class="codeuno" style="border-collapse:collapse" borderColor="#336699" height="20" cellSpacing="0" cellPadding="0" width="100%" border="1" align="left" bgcolor="#FF6600">
  <tr>
    <td borderColorLight="#000000" borderColorDark="#488cc8" align="center"><a href="http://www.zumorecords.com"><font color="Whitesmoke">Home</a> </font>
      </a> </td>
    <td borderColorLight="#000000" borderColorDark="#488cc8" align="center"><a href="../index.php?id=somos"><font color="Whitesmoke">¿Quienes Somos?</font>
      </a>
 </td>
    <td borderColorLight="#000000" borderColorDark="#488cc8" align="center"><a href="../index.php?id=pago"><font color="Whitesmoke">Política de Pago  </font>
      </a>  
 </td>
    <td borderColorLight="#000000" borderColorDark="#488cc8" align="center"><a href="../index.php?id=cliente"><font color="Whitesmoke">Política de Cliente </font>
      </a> 
 </td>
    <td borderColorLight="#000000" borderColorDark="#488cc8" align="center"><a href="../index.php?id=contacto"><font color="Whitesmoke">Contacto</a></td>
  </tr>
</table>

    
    </td>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780">
  <tr>
    <td width="100%">
      <p align="right"><a class="codeuno" href="estado.php">Ver Carrito</a> / <a class="codeuno" href="formulario.php">Formulario(Hacer
      pedido)</a></td>
  </tr>
</table>
<table width="780" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">

<td></td>
<td class="blockrightcontent"></td>
<td class="blockrightcontent" width="150" valign="top">
<table border="0" cellpadding="3" cellspacing="3" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
  <tr>
    <td width="100%"><table cellpadding=0 cellspacing=0 border=0>
<form name="sf1" action="index.php">
<tr>
<td>
<select name="palabra" onChange="changesubmit('sf1', 'palabra');" class="codedos">
<option value="">House
<option value="">-------------------------
<option value="House">House
<option value="House Tribal">House Tribal
<option value="House Vocal">House Vocal
<option value="House Deep">House Deep
<option value="House Hard">House Hard
<option value="House Tech">House Tech
<option value="House Disco">House Disco
<option value="House Funky">House Funky
<option value="House Progressive">House Progressive
</select>
<p>&nbsp;</p>
</td>
</tr>

</form>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<form name="sf2" action="index.php">
<tr>
<td>
<select name="palabra" onChange="changesubmit('sf2', 'palabra');" class="codedos">
<option value="">Techno
<option value="">-------------------------
<option value="techno" selected>Techno
<option value="Techno House">Techno House
<option value="Techno Detroit">Techno Detroit
<option value="Techno Minimal">Techno Minimal
<option value="Techno Tribal">Techno Tribal
</select>
<p>&nbsp;</p>
</td>
</tr>


</form>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<form name="sf3" action="index.php">
<tr>
<td>
<select name="palabra" onChange="changesubmit('sf3', 'palabra');" class="codedos">
<option value="">Progressive
<option value="">-------------------------
<option value="Progressive House">Progressive House
<option value="Progressive Trance">Progressive Trance
</select>
<p>&nbsp;</p>
</td>
</tr>


</form>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<form name="sf4" action="index.php">
<tr>
<td>
<select name="palabra" onChange="changesubmit('sf4', 'palabra');" class="codedos">
<option value="">Trance
<option value="">-------------------------
<option value="Trance Hard">Trance Hard
<option value="Trance Psy">Trance Psy
</select>
<p>&nbsp;</p>
</td>
</tr>
</form>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<form name="sf5" action="index.php">
<tr>
<td>
<select name="palabra" onChange="changesubmit('sf5', 'palabra');" class="codedos">
<option value="">Hip Hop/Scratch/Other
<option value="">-------------------------
<option value="Hip Hop">Hip Hop
<option value="Break Beat">Break Beat
<option value="Compilation">Compilation
<option value="Downtempo">Downtempo
<option value="D&amp;B">D&amp;B
<option value="Ambient">Ambient
<option value="Electro">Electro
</select></form>
</td>
</tr>
</table>
<table border="1" cellpadding="3" cellspacing="0" width="100%" bordercolor="#FFFFFF">
  <tr>
    <td width="100%"><FORM class="codeuno" method="post" action="../maillist/enviar.php" target="_top">
<p align="center">
Inscribete a nuestro mail listing y recibe noticias de los New Releases y
Restocks.
<input type="text" name="Lista_de_Email" size="15"><br>
<input type="submit" value="Inscribir">
</form></td>
  </tr>
</table>
</td>
  </tr>
</table>
<p>&nbsp;</p>
<table border="0" cellpadding="3" cellspacing="0" width="150" height="375">
  <tr valign="top">
  </tr>
</table>
</td>
    <td></font></td>
<td width="100%">
<table border="0" width="100%" cellpadding="10" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr><td>
<SCRIPT LANGUAGE="JavaScript">
    showItems();
</SCRIPT>
<p>
[ <a href="javascript:clearBasket()">Quitar todos los artículos del carrito</a> ]   [ <a href="javascript:history.back()">Regresar</a> ]
</td></tr></table></td>
<td></td>
</tr>
</table>
  <br>    
</body> 
Como le hago para mostrar el total de los productos seleccionados tambien donde está la "p"
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:56.