I use this JS to create 3 state mouse events (norm, omo & click):
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
var base= "img/prod/mo_";
var nrm = new Array();
var omo = new Array();
var ocl = new Array();
var stuff = new Array('1shirt','2shirts','3shirts');
var select = 3;
var name2 = "";
var temp = 0;
// Pre-load part.
if (document.images)
{
for (i=0;i<stuff.length;i++)
{
nrm[i] = new Image;
nrm[i].src = base + stuff[i] + "_norm.jpg"
omo[i] = new Image;
omo[i].src = base + stuff[i] + "_omo.jpg";
ocl[i] = new Image;
ocl[i].src = base + stuff[i] + "_clic.jpg";
}
}
// The functions: first mouseover, then mouseout
function over(no)
{
if (document.images && select != no)
{
document.images[stuff[no]].src = omo[no].src
}
}
function out(no)
{
if (document.images && select != no)
{
document.images[stuff[no]].src = nrm[no].src
}
}
function clic(no)
{
if (document.images)
{
document.images[stuff[no]].src = ocl[no].src
temp = select;
select = no;
if (temp != -1) {out(temp)}
}
}
// -->
</SCRIPT>
and this is in the body:
<?php
$count = 1;
foreach($products as $product) {
?>
<li class="product<?php echo $count; ?><?php if ($count == 1) { echo ' selected'; }?>">
<a href="#"
data-price="<?php echo $product['price'];?>"
data-proddesc="<?php echo $product['desc']; ?>"
data-prodcode="<?php echo $product['id'];?>"
data-shipcost="<?php echo $product['ship_cost'];?>"
data-shipid="<?php echo $product['ship_id'];?>"
data-prodname="<?php echo $product['name'];?>"
data-imagename="<?php echo $product['image_name']; ?>"
data-imagesrc="<?php echo $product['image_path']; ?>"
data-imagemo="<?php echo $product['image_path_omo']; ?>"
data-imagecl="<?php echo $product['image_path_clic']; ?>"
" onMouseOver="over(0)" onMouseOut="out(0)" onClick="clic(0)";>" // How can I pass the variables. If I write it like this: just the first image have effect - and I need all 3 of them.
Bookmarks