2014-06-13 6 views
-1

Ma fonction est:événement onClick ne

<head> 
<script type="text/javascript"> 
// Info popup window 
function showInfo(infFilename) { 
alert(infFilename); 
popupWin = window.open('notes/"+infFilename+"','open_window','width=400,height=300,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=20,top=20'); 
} 
</script> 
</head> 

Le code php appeler le menu contextuel est:

<?php> 
// check if metadata exists (PicNotes is "filename.php") 
if ($row['PicNotes']) { 
$icon = "<img src = \"images/info.png\" onClick=\"showInfo($row[PicNotes])\" />"; 
}else{ 
$icon='';} 

echo "<a href='images/".$row['vfile']."' rel='enlargeimage' rev='targetdiv:loadarea' title='&lt;b&gt;".$row['Title']."&lt;/b&gt;&lt;br /&gt;".$row['Medium']." &nbsp; &nbsp; &nbsp; ".$row['iw']." x ".$row['ih']." cm. $icon'><img border='1' src='images/".$row['tnfile']." ' alt=' ' width='".$row['tnx']."' height='".$row['tny']."' class='tn' /></a><br />"; 

?> 

Le code HTML de cette ligne est (de source):

<a href='images/0712120189y.jpg' rel='enlargeimage' rev='targetdiv:loadarea' title='&lt;b&gt;Broken Bridge in Water Meadow&lt;/b&gt;&lt;br /&gt;Gouache &amp; Pastel &nbsp; &nbsp; &nbsp; 24 x 19 cm. <img src = "images/info.png" onClick="showInfo(wm_series.php)" />'><img border='1' src='images/0712120189z.jpg ' alt=' ' width='96' height='75' class='tn' /></a> 

S'il vous plaît quelqu'un peut voir ce que je fais mal.

+0

'showInfo ('wm_series.php') 'a besoin de guillemets autour du nom. –

+0

Jetez un oeil au code HTML du ' Barmar

Répondre

0

Cette partie:

onClick=\"showInfo($row[PicNotes])\" 

devrait être:

onClick=\"showInfo('$row[PicNotes]')\" 

Vous devez entre guillemets l'argument de nom, car il est une chaîne.

En outre, vous avez un des personnages ici:

cm. $icon'> 

Il devrait être:

cm. $icon 

Votre code popup doit être:

function showInfo(infFilename) { 
    alert(infFilename); 
    popupWin = window.open('notes/'+infFilename,'open_window','width=400,height=300,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=20,top=20'); 
} 
+0

Thenks Barmar but I have already tried that but is stops php processing the line properly. The output becomes:
' '> ' – Sabreur

+0

Cette sortie me semble correcte. – Barmar

+0

guillemets doubles et les échapper produisent le même résultat. – Sabreur