Jump to content

Recommended Posts

Hello Guys,

 

I have a page with thumb nails and a large image that changes when clicking on thumbnail. I need to display dynamic title for the image. It wont display because the page is not reloading.. How do you pass the name so it will show up without reloading?

 

Here is the JS for switching dynamically loading the large image

 

<script language="javascript">
$(document).ready(function() {
    $('.thumbnail').live("click", function() {
        $('#mainImage').hide();
        $('#atitle').hide();
        $('#imageWrap').css('background-image', "url('/images/ajax-loader.gif')");
        var i = $('<img />').attr('src',this.href).load(function() {
            $('#mainImage').attr('src', i.attr('src'));
             $('#imageWrap').css('background-image', 'none');
            $('#mainImage').fadeIn();
             $('#atitle').fadeIn();
            
           
        });
        return false; 
    });
});
</script>

 

Here is the link for the thumb

 

  // Thumbnail Display
             
             echo '<a href="artists/'.$artist.'/'.$imgname.'.jpg" class="thumbnail"><img src="artists/'.$artist.'/previews/'.$imgname.'.jpg" border="0" /></a>';

 

[/code]

 

Link to the large image

 

  // Large image display              
                            echo '<img src="artists/'.$artist.'/'.$first_image.'.jpg" alt="Main Image" id="mainImage"/>';

 

Here is the php echo for the title

<? echo  str_replace('"', '`',  $iname); ?>

 

I need to some how pass a php var from the thumb link to the js and have it display dynamically (Without Reloading)

 

Hope I explained this correctly.. Please advise..

 

Thanks, Dan

Link to comment
https://forums.phpfreaks.com/topic/258581-passing-a-php-var-to-javascript/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.