Script ne fonctionnant pas avec Opera

max300647 Messages postés 2 Date d'inscription vendredi 7 janvier 2005 Statut Membre Dernière intervention 17 novembre 2008 - 17 nov. 2008 à 10:02
PetoleTeam Messages postés 3426 Date d'inscription lundi 26 décembre 2005 Statut Membre Dernière intervention 14 janvier 2011 - 18 nov. 2008 à 18:36
Bonjour

J'utilise un code javascript écrit par Zhong Yang et optimisé par Guy Cappra. Ce code qui permet de voir le "panier" fonctionne bien sur IE, Firefox , Safari, Navigator ou Chrome sauf sur Opera 9.62 et je n'arrive pas à trouver le bug (je débute sur javascript). Il m'écrit bien la ligne d'entête du tableau, mais pas les lignes des produits commandés. Pourriez vous m'aider?
Voici le code:
function view_cart() {
   mycookies= new Array(20);
   var i=0;
   var startpoint=0;
   whole_len=document.cookie.length;
   while(whole_len!=startpoint && i< 20)
   {
     if ((temlen=document.cookie.indexOf(";",startpoint))!=-1)
     {
    mycookies[i]=document.cookie.substring(startpoint,temlen);
    i++;
    startpoint=temlen+1
     }
     else if (startpoint != whole_len)
     {
        mycookies[i]=document.cookie.substring(startpoint,whole_len);
        i++;
        startpoint=whole_len;
     }
   }
    printtitle();
    for (j=0;j");
}

function getCookie (acookie) {
   
  
 clen = acookie.length;
    nlen= acookie.indexOf("=",0);
    //get rid of the "crea" at the beginning, thus start at 4
    if(acookie.substring(0,1)==" ")
       cname=acookie.substring(5,acookie.indexOf("=",0));
    else
       cname= acookie.substring(4,acookie.indexOf("=",0));
    bname= acookie.substring(acookie.indexOf("=",0)+1,acookie.length);
    sname_len=cname.indexOf("+",0);
    store=cname.substring(0,cname.indexOf("+",0));
    dlen=cname.indexOf("+",cname.indexOf("+",0)+1);
    descrip=cname.substring(cname.indexOf("+",0)+1,cname.indexOf("+",cname.indexOf("+",0)+1))
    product=cname.substring(cname.indexOf("+",cname.indexOf("+",0)+1)+1,acookie.indexOf("=",0));

    qlen=acookie.substring(acookie.indexOf("=",0)+1,acookie.length).indexOf("+",0);
    rlen=acookie.substring(acookie.indexOf("=",0)+1,acookie.length).indexOf("+",acookie.substring(acookie.indexOf("=",0)+1,acookie.length).indexOf("+",0)+1);
    quant=acookie.substring(acookie.indexOf("=",0)+1,acookie.length).substring(0,acookie.substring(acookie.indexOf("=",0)+1,acookie.length).indexOf("+",0));
    if(quant==0)
    document.cookie="crea"+cname+"=bb; expires=Saturday, 16-Sep-90 23:59:59 GMT; path=/"+"";

    refer=acookie.substring(acookie.indexOf("=",0)+1,acookie.length).substring(acookie.substring(acookie.indexOf("=",0)+1,acookie.length).indexOf("+",0)+1,acookie.substring(acookie.indexOf("=",0)+1,acookie.length).indexOf("+",acookie.substring(acookie.indexOf("=",0)+1,acookie.lengt);
    price=acookie.substring(acookie.indexOf("=",0)+1,acookie.length).substring(acookie.substring(acookie.indexOf("=",0)+1,acookie.length).indexOf("+",acookie.substring(acookie.indexOf("=",0)+1,acookie.lengt+1,acookie.length-acookie.indexOf("=",0))*quant;
    price=price_format(price);
    printcontent();
}

function putback(str1){
  document.cookie="crea"+str1+";  path=/"+"";
}

// There's no need to touch anything above this line
// You can use "cname.substring(0,cname.indexOf("+",0))","descrip","product","quant","price"
// and "refer" in the code below

function printtitle(){
document.write("<TABLE WIDTH=100% BORDER=0 align=center><tr> \
<TD WIDTH=25% BGCOLOR=#800000 BORDERCOLOR=#FFFFFF> Produit </td> \
<TD WIDTH =61% BGCOLOR= #800000 BORDERCOLOR=#FFFFFF> D&eacute;signation </td> \
<TD WIDTH =4% Align= CENTER BGCOLOR=#800000 BORDERCOLOR=#FFFFFF> Qt&eacute; </td> \
<TD WIDTH =10% Align= CENTER BGCOLOR=#800000 BORDERCOLOR=#FFFFFF> Montant TTC </td> \
<td> </td></tr><tr></tr><tr></tr><tr></tr><tr></tr>");
}

function printcontent(){
  if(quant! =0){
    document.write("<tr align= LEFT><TD WIDTH=25% VALIGN=TOP> "+product+" </td><TD WIDTH =61% VALIGN= TOP>");
    document.write(descrip+"</td><TD WIDTH=4% Align=CENTER VALIGN=TOP> "+quant+" </td><TD WIDTH =10% align=RIGHT VALIGN=TOP>");
    document.write(price+"</td>");
    document.write("<TD><form></form></td></tr>");
   }
}

//add a field so that shopper can change amount of product in cart
function printcontent2(){
  if(quant!=0){
    document.write("<tr align=center><td>"+product+"</td><td>");
    document.write(descrip+"</td><td><form method=get ");
    document.write("action=voir.html>");
    document.write("");
    document.write("</td><td>");
    document.write(price+"</td><td>"+"[+refer+ "+store+"]");
    document.write("</td><td>");
    document.write("</form></td></tr>");
   }
}

function price_format(tmpprice){
// get rid off the extra digits behind "."
   dot = tmpprice.toString().indexOf(".");
   if(dot!=-1)
      tmpprice=tmpprice.toString().substr(0,dot+4);
   tmpprice=Math.round(tmpprice*100)/100;
// add "0" if necessary
   dot = tmpprice.toString().indexOf(".");
   if(dot ==-1)
      tmpprice=tmpprice.toString()+".00";
   else if((tmpprice.toString().length-dot)==2)
      tmpprice=tmpprice.toString()+"0";
   return tmpprice;
}

Merci d'avance

3 réponses

max300647 Messages postés 2 Date d'inscription vendredi 7 janvier 2005 Statut Membre Dernière intervention 17 novembre 2008
17 nov. 2008 à 10:27
Rebonjour


Le code transmis n'était pas le bon: Voici le bon code:


mycookies= new Array(20);
   var i=0;
   var startpoint=0;
   whole_len=document.cookie.length;
   while(whole_len!=startpoint && i< 20)
   {
     if ((temlen=document.cookie.indexOf(";",startpoint))!=-1)
     {
 mycookies[i]=document.cookie.substring(startpoint,temlen);
 i++;
 startpoint=temlen+1
     }
     else if (startpoint != whole_len)
     {
        mycookies[i]=document.cookie.substring(startpoint,whole_len);
        i++;
        startpoint=whole_len;
     }
   }
    printtitle();
    for (j=0;j");
}




function getCookie (acookie) {
    clen = acookie.length;
    nlen= acookie.indexOf("=",0);
    //get rid of the "crea" at the beginning, thus start at 4
    if(acookie.substring(0,1)==" ")
       cname=acookie.substring(5,nlen);
    else
       cname= acookie.substring(4,nlen);
    bname= acookie.substring(nlen+1,clen);
    sname_len=cname.indexOf("+",0);
    store=cname.substring(0,sname_len);
    dlen=cname.indexOf("+",sname_len+1);
    descrip=cname.substring(sname_len+1,dlen)
    product=cname.substring(dlen+1,nlen);


    qlen=bname.indexOf("+",0);
    rlen=bname.indexOf("+",qlen+1);
    quant=bname.substring(0,qlen);
    if(quant==0)
 document.cookie="crea"+cname+"=bb; expires=Saturday, 16-Sep-90 23:59:59 GMT; path=/"+"";


    refer=bname.substring(qlen+1,rlen);
    price=bname.substring(rlen+1,clen-nlen)*quant;
    price=price_format(price);
    printcontent();
}


function putback(str1){
  document.cookie="crea"+str1+"=bb; expires=Saturday, 16-Sep-90 23:59:59 GMT; path=/"+"";
}


// There's no need to touch anything above this line
// You can use "store","descrip","product","quant","price"
// and "refer" in the code below


function printtitle(){
tabletitle="<TABLE WIDTH=100% BORDER=0 align=center><tr> \
<TD WIDTH=25% BGCOLOR=#800000 BORDERCOLOR=#FFFFFF> Produit </td> \
<TD WIDTH =61% BGCOLOR= #800000 BORDERCOLOR=#FFFFFF> D&eacute;signation </td> \
<TD WIDTH =4% Align= CENTER BGCOLOR=#800000 BORDERCOLOR=#FFFFFF> Qt&eacute; </td> \
<TD WIDTH =10% Align= CENTER BGCOLOR=#800000 BORDERCOLOR=#FFFFFF> Montant TTC </td> \
<td> </td></tr><tr></tr><tr></tr><tr></tr><tr></tr>";
document.write(tabletitle);
}


function printcontent(){
  if(quant! =0){
    document.write("<tr align= LEFT><TD WIDTH=25% VALIGN=TOP> "+product+" </td><TD WIDTH =61% VALIGN= TOP>");
    document.write(descrip+"</td><TD WIDTH=4% Align=CENTER VALIGN=TOP> "+quant+" </td><TD WIDTH =10% align=RIGHT VALIGN=TOP>");
    document.write(price+"</td>");
    document.write("<TD><form></form></td></tr>");
   }
}


//add a field so that shopper can change amount of product in cart
function printcontent2(){
  if(quant!=0){
    document.write("<tr align=center><td>"+product+"</td><td>");
    document.write(descrip+"</td><td><form method=get ");
    document.write("action=voir.html>");
    document.write("");
    document.write("</td><td>");
    document.write(price+"</td><td>"+"[+refer+ "+store+"]");
    document.write("</td><td>");
    document.write("</form></td></tr>");
   }
}


function price_format(tmpprice){
// get rid off the extra digits behind "."
   dot = tmpprice.toString().indexOf(".");
   if(dot!=-1)
      tmpprice=tmpprice.toString().substr(0,dot+4);
   tmpprice=Math.round(tmpprice*100)/100;
// add "0" if necessary
   dot = tmpprice.toString().indexOf(".");
   if(dot ==-1)
      tmpprice=tmpprice.toString()+".00";
   else if((tmpprice.toString().length-dot)==2)
      tmpprice=tmpprice.toString()+"0";
   return tmpprice;
}
0
Bul3 Messages postés 4933 Date d'inscription samedi 1 juillet 2006 Statut Membre Dernière intervention 2 février 2015 16
17 nov. 2008 à 12:59
>>Voici le bon code:
euh... tu veux dire le mauvais je pense ? non ? ;o)

mais là, tu ne nous donne que le javascript....
       difficile de tester tel quel, donc de voir....

une url, c'est possible ?

Cordialement

          Bul [mon Site] [M'écrire]         
0
PetoleTeam Messages postés 3426 Date d'inscription lundi 26 décembre 2005 Statut Membre Dernière intervention 14 janvier 2011 17
18 nov. 2008 à 18:36
Bonjour,
Rien de ce que je peux lire ne concerne
un quelconque navigateur en particulier...
Est ce que la configuration de
ton Opéra accepte les cookies ?
;O)
0
Rejoignez-nous