[Javascript + PHP] Problème de quotes ?

sluggogle -  
 titugo63 -
Bonjour,

J'ai defini une variable avec une boucle while php :

//----------------------------------------------------
while ($data3 = mysql_fetch_array($go3))
{
$ce = $data3['ID_CE'];
}
//---------------------------------------------------

J'ai aussi une fonction en Javascript qui demande confirmation :

//--------------------------------------------------------
function confirmation(message,action)
{
if(confirm(message)) {eval(action);}
}
//--------------------------------------------------------

Un lien a faire en cas de confirmation :

//--------------------------------------------------------
$action = "window.location.href='index.php?page=traitement&categorie=2&action=1&id=".$ce."'"
//--------------------------------------------------------

Et finalement l'application du tout :

//-------------------------------------------------------
onClick="confirmation('Supprimer ?','<?php echo $action;?>')"
//-------------------------------------------------------

Je pense que mon soucis vient des quotes. A cause de la simple quote qui indique le debut du lien --> 'index.php ...'
A moins que les triples quotes existe il y a t'il une solution a mon problème ou alors une méthode complètement différente ?

Merci d'avance ^^

4 réponses

  1. sluggogle
     
    Je viens de regarder le message et je me suis apercu qu'il s'affiche mal :

    le lien est bien :

    $action = "window.location.href='index.php?page=traitement&categorie=2&action=1&id=".$ce. " ' "
    0
  2. sluggogle
     
    UP !

    s'il vous plait un coup de main, je vois pas du tout comment continuer
    0
  3. sluggogle
     
    Re,

    bien j'ai trouver la solution.

    Dans le lien : $action = "window.location.href='index.php?page=traitement&categorie=2&action=1&id=".$ce. " ' "

    Il suffite de mettre un \ : $action = "window.location.href=\'index.php?page=traitement&categorie=2&action=1&id=".$ce. "\ ' "

    voila pour ceux que ca peut aider
    0
    1. narfy892
       
      Bonjour,
      J’ai un problème similaire mais un peu plus complexe que je ne parviens pas à solutionner.
      Merci d’avance pour votre aide.
      0
      1. narfy892 > narfy892
         
        ceci ne fontionne pas

        document.getElementById('JavaSidebarPh').innerHTML = "<a href='#' onclick='document.getElementById(\'JavaMainContent\').innerHTML=\'<table><tr><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-06-14/images.jpg\\\'></td><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-06-14/imagesqsdfq.jpg\\\'></td><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-06-14/imagessdfsdf.jpg\\\'></td></tr></table>\''>2008-06-14</a><br><a href='#' onclick='document.getElementById(\'JavaMainContent\').innerHTML=\'<table><tr><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-10-19/images f.jpg\\\'></td><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-10-19/images.jpg\\\'></td></tr></table>\''>2008-10-19</a><br>";

        et ceci ne fonctionne avec ie7 uniquement

        document.getElementById('JavaSidebarPh').innerHTML = "<a href='#' onclick=`document.getElementById(\'JavaMainContent\').innerHTML=\'<table><tr><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-06-14/images.jpg\\\'></td><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-06-14/imagesqsdfq.jpg\\\'></td><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-06-14/imagessdfsdf.jpg\\\'></td></tr></table>\''>2008-06-14</a><br><a href='#' onclick='document.getElementById(\'JavaMainContent\').innerHTML=\'<table><tr><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-10-19/images f.jpg\\\'></td><td><img width=\\\'100px\\\' height=\\\'100px\\\' src=\\\'site/foot/pictures/2008-10-19/images.jpg\\\'></td></tr></table>\'`>2008-10-19</a><br>";
        0
  4. titugo63
     
    il existe l'entrée EOF, comme dans la console UNIX :

      
    <<<EOF   
    
    Du texte avec toutes sortes de quotes :   
    " ' " '' ""   
    
    Fin de l'entrée avec les termes inscrits plus hauts à savoir :   
    
    EOF   
    
    0