$("#logo").find('option').hover(function() { generateLogos($(this).val()); }); function generateLogos(which) { $("#div").html('<center>Loading image...</center>'); $("#div").html('<img src=""quot;"quot;'+which+'" ></img>'); }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
// connexion à la BD
require_once("connexion_db.php");
$sql = "SELECT * FROM article";
$req = $db->prepare($sql);
$req->execute() or die(print_r($req1->errorInfo()));
$rows = $req->fetchAll();
<select name="logos" id="logo">
<option value="">Choisir votre logo :</option>
<option value="">Aucun logo</option>
<?php
foreach($rows as $row) {
?>
<option value="<?=$row['article_ref'];?>">
<?=$row['article_lib'];?>
</option>
<?php } ?>
</select>
<div id="div"></div>
function generateLogos() {
var which = this.value;
var src=""quot;images/%article_ref%.jpg";
src=""rc.replace("%article_ref%", which);
$("#div").html('<center>Loading image...</center>');
$("#div").html('<img src=""quot;'+src +'">');
}
$("#logo").find('option').hover(function() {
generateLogos;
});
or die(print_r($req1->errorInfo()));
<select size="7" name="logos" id="logo">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TEST</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <script type="text/javascript" src=""quot;jquery.js"></script> <style> .dropbtn { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; cursor: pointer; } .dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover { background-color: #f1f1f1; } .dropdown:hover .dropdown-content { display: block; } .dropdown:hover .dropbtn { background-color: #3e8e41; } </style> </head> <body> <div class="dropdown"> <button class="dropbtn">Dropdown</button> <div class="dropdown-content" id="logo"> <a href="#" rel="nofollow noopener noreferrer" target="_blank" data-img='logo1.jpg'>Link 1</a> <a href="#" rel="nofollow noopener noreferrer" target="_blank" data-img='logo2.jpg'>Link 2</a> <a href="#" rel="nofollow noopener noreferrer" target="_blank" data-img='logo3.jpg'>Link 3</a> </div> </div> </body> </html> <div id="div"></div> <script type="text/javascript"> $(document).ready(function(event) { $("#logo a").hover(function() { var img = $(this).data('img'); console.log(img); generateLogos(img); }); function generateLogos(which) { $("#div").html('<center>Loading image...</center>'); $("#div").html('<img src=""quot;"quot;"quot;'+which+'" ></img>'); } }); </script> </body> </html>