hi,
my purpose of my code is to get an array of subcategory details
and format it and when when mouse over some subcategory
- an image will change (dynamically).
this code is PHP with Javascript
My problem is how can i get the variable 'key1' from the javascript
funtion to the PHP which echoes the .src
here: (key1 is the a key number is an array of images)
document.getElementById("cat_subcat_img").src="<?php echo IMG_SUBCAT_DIR.$subcat_img1["key1"]; ?>";
my full code:
foreach($subcat as $key => $val) { //inner foreach
$subcat_id = $val['id'];
$sub_category = $val['subcat'];
$subcat1 = array( );
$subcat_img1[] = $val['img'] ; ?>
<script language="Javascript1.2" type="text/javascript">
function changeSrc_subcat1(key1) {
document.getElementById("cat_subcat_img").src="<?php echo IMG_SUBCAT_DIR.$subcat_img1["key1"]; ?>";
}
</script>
<tr valign="top">
<td valign="top" align="left" nowrap="nowrap">
<!-- LINK to display products of the current sub category -->
<a href="shw_subcat_prod.php?subcatID=<?php echo $subcat_id; ?>" class="subcat" onMouseOver="changeSrc_subcat1(<?php echo $key; ?>)"><?php echo $sub_category; ?></a>
</td>
</tr>
<?php
} //end foreach