我正在使用 php 填充缩略图库。当我单击拇指时,我运行一个 javascript 函数,我想在其中将我单击的照片放在一个名为 viewer 的 div 中。我不知道在我的功能中怎么说。
这是我到目前为止所拥有的
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>img.thumb{height:100px; display:inline-block;} .thumb{position:relative; display:inline-block;}</style>
<script type="text/javascript">
function showfull(){
console.log("hello");
document.getElementById("viewer").innerHTML = "<? echo '<img onclick="showfull();" id="'.$thispic.'" class="thumb" src = "../images/'.$pic.'"/><br/><h1 id="'.$thistitle.'" class="title">'.$maruja['pictitle'].'</h1><br/><h2 id="'.$thisdescript.'" class="description">'.$maruja['picdesc'].'</h2>'; ?>";
}
</script>
</head>
<body>
<?
//show categories in dropdown
$sql = $dbh->prepare("select * from 3304gallcats");
$sql->execute();
while ($carolyn = $sql->fetch()){
echo '<a href = "index.php?catid='.$carolyn['catid'].'">'.$carolyn['catname'].'</a><br/>';
}
$catid = $_GET['catid'];
$picsql = $dbh->prepare("select * from 3304gallpix where catid = '$catid'");
$picsql->execute();
while ($maruja = $picsql->fetch()){
$pic = $maruja['id'].'.jpg' ;
$thispic = 'num'.$maruja['id'].'pic';
$thistitle = 'num'.$maruja['id'].'title';
$thisdescript = 'num'.$maruja['id'].'descript';
echo '<img onclick="showfull();" id="'.$thispic.'" class="thumb" src = "../images/'.$pic.'"/><br/><h1 id="'.$thistitle.'" class="title">'.$maruja['pictitle'].'</h1><br/><h2 id="'.$thisdescript.'" class="description">'.$maruja['picdesc'].'</h2>';
//echo '<img src = "./thumbnail.php?pic=../images/'.$pic.'&ht=100&wd=100"/><br/>'.$maruja['pictitle'].'<br/>'.$maruja['picdesc'];
}
?>
<div id="viewer"></div>
</body>