...

View Full Version : Image onclick (PHP)



traucostar
05-17-2009, 07:29 AM
Hello,
Hope someone can help me, I dont know were to put this thread because it has javascript and some PHP. Here is my question: I have a list of images in my folder named: 1.jpg, 2.jpg, 3.jpg etc... All images are displayed on a white div, and when users click on the image, the backgound of the div changes to orange. But I dont know how to reverse that, from orange to white, onclick. Thanks!



<script type="text/javascript">
<?php
$i = 1;
while ($i < 6)
{
?>
function ponerborde<?php echo $i; ?>(here)
{
var imgTag = "<div style='height:77px; width:102px; background-color: #F60; display:table-cell; position:relative; vertical-align:middle;'><img src='<?php echo base_url().$i; ?>.jpg' onclick='ponerborde<?php echo $i; ?>(<?php echo $i; ?>)'/>";

var obj = document.getElementById(here);
obj.innerHTML = imgTag;
}
<?php
$i++;
}
?>
</script>

<?php
$i = 1;
while ($i < 6)
{
?>
<div id="<?php echo $i; ?>" style="display:table; float:left;text-align:center;vertical-align:middle;">
<div style="height:77px; width:102px; background-color: #FFF; display:table-cell; position:relative; vertical-align:middle;">
<img src="<?php echo base_url().$i; ?>.jpg" onclick="ponerborde<?php echo $i; ?>(<?php echo $i; ?>)"/>
</div>
</div>
<div class="vacio">
</div>
<?php
$i++;
}

?>

student101
05-17-2009, 09:23 PM
seven-togglers (http://www.google.co.za/search?hl=en&q=seven-togglers&btnG=Search&meta=)

Click the first one...
Cheers



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum