I have some code that worked not bad, until I've added PHP to it. The problem may be with right around line 12 where I am trying to get the variable in the first place:
The other possibility is where the element ID is assigned:
Using some cleverly placed alert boxes the only thing that is getting passed forward is "[object HTMLImageElement]" but not the element ID.
Shouldn't need AJAX because I am NOT trying to pass JavaScript variable to PHP. Rather, it is the other way around, which should be kosher.
Here is the code:
Code:
function expander(RecordID){
The other possibility is where the element ID is assigned:
Code:
echo "<img id='".$row['IDNumber']."' src=".$row['ImagePath']." width='5%' onMouseOver='expander(".$row['IDNumber'].");' onMouseOut='shrinker(".$row['IDNumber'].");'>";}
Using some cleverly placed alert boxes the only thing that is getting passed forward is "[object HTMLImageElement]" but not the element ID.
Shouldn't need AJAX because I am NOT trying to pass JavaScript variable to PHP. Rather, it is the other way around, which should be kosher.
Here is the code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="class.css" />
<script type = "text/javascript" language="javascript">
//<![CDATA[
var maxheight = 150;
var countShrink = 1;
function expander(RecordID){
alert(RecordID);
var countGrow = 1;
var pic = document.getElementById(RecordID);
if(pic){
var imageh = pic.height;
var imagew = pic.width;
if(imageh<100){
countGrow++;
imageh = imageh*1.2;
imagew = imagew*1.2;
pic.style.height = imageh + "px";
pic.style.width = imagew + "px";
var timer = window.setTimeout(function(){expander(RecordID);},2);}
}
else
{alert("error on");}
}
function shrinker(RecordID){
var pic = document.getElementById(RecordID);
if(pic){var counter = 1
var imageh = pic.height;
var imagew = pic.width;
if(imageh>20){
imageh = imageh/1.2;
imagew = imagew/1.2;
pic.style.height = imageh + "px";
pic.style.width = imagew + "px";
var timer = window.setTimeout(function(){shrinker(RecordID);},3);}
}
else
{alert("error off");}
}
//]]>
</script>
</head>
<body>
<?php
include('menuSub.html');
require_once('connect.php');
$idnum = 'phmdv06tbu';
//$q="SELECT * FROM art WHERE IDNumber = '".$idnum."'";
$q="SELECT * FROM art ORDER BY IDNumber LIMIT 4";
$r = @mysqli_query ($dbc, $q);
echo "<div class='bodyContent'><div class='imageContent'>";
if($r){
while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)){
echo "<img id='".$row['IDNumber']."' src=".$row['ImagePath']." width='5%' onMouseOver='expander(".$row['IDNumber'].");' onMouseOut='shrinker(".$row['IDNumber'].");'>";}
}
else{
echo '<div class="bodyContent"> Error<div>';
}
echo "</div></div>";
mysqli_close($dbc); ?>
</body>
</html>