Note that there are some explanatory texts on larger screens.

plurals
  1. POmaking a gallery with php and javascript
    text
    copied!<p>I'm using php to populate a thumbnail gallery. When I click on the thumb I run a javascript function in which I want to put the photo that I clicked on in a div called viewer. I don't know how to say that in my function.</p> <p>here's what I have so far</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;style&gt;img.thumb{height:100px; display:inline-block;} .thumb{position:relative; display:inline-block;}&lt;/style&gt; &lt;script type="text/javascript"&gt; function showfull(){ console.log("hello"); document.getElementById("viewer").innerHTML = "&lt;? echo '&lt;img onclick="showfull();" id="'.$thispic.'" class="thumb" src = "../images/'.$pic.'"/&gt;&lt;br/&gt;&lt;h1 id="'.$thistitle.'" class="title"&gt;'.$maruja['pictitle'].'&lt;/h1&gt;&lt;br/&gt;&lt;h2 id="'.$thisdescript.'" class="description"&gt;'.$maruja['picdesc'].'&lt;/h2&gt;'; ?&gt;"; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;? //show categories in dropdown $sql = $dbh-&gt;prepare("select * from 3304gallcats"); $sql-&gt;execute(); while ($carolyn = $sql-&gt;fetch()){ echo '&lt;a href = "index.php?catid='.$carolyn['catid'].'"&gt;'.$carolyn['catname'].'&lt;/a&gt;&lt;br/&gt;'; } $catid = $_GET['catid']; $picsql = $dbh-&gt;prepare("select * from 3304gallpix where catid = '$catid'"); $picsql-&gt;execute(); while ($maruja = $picsql-&gt;fetch()){ $pic = $maruja['id'].'.jpg' ; $thispic = 'num'.$maruja['id'].'pic'; $thistitle = 'num'.$maruja['id'].'title'; $thisdescript = 'num'.$maruja['id'].'descript'; echo '&lt;img onclick="showfull();" id="'.$thispic.'" class="thumb" src = "../images/'.$pic.'"/&gt;&lt;br/&gt;&lt;h1 id="'.$thistitle.'" class="title"&gt;'.$maruja['pictitle'].'&lt;/h1&gt;&lt;br/&gt;&lt;h2 id="'.$thisdescript.'" class="description"&gt;'.$maruja['picdesc'].'&lt;/h2&gt;'; //echo '&lt;img src = "./thumbnail.php?pic=../images/'.$pic.'&amp;ht=100&amp;wd=100"/&gt;&lt;br/&gt;'.$maruja['pictitle'].'&lt;br/&gt;'.$maruja['picdesc']; } ?&gt; &lt;div id="viewer"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload