Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Creating a jquery function to display an image

    Hi guys. I'm a beginner using jquery and javascript and I have almost a week trying to figure this out but I can't come up with a solution.

    I have a catalog for shoes. I have a description page where people select sizes and colors of shoes. I have a product detail page called (product_det.php) where people select shoes sizes and send the value to (ajax_items.php) which does a search and lists all colors found using shoes images. Then when you click over the shoe color image, that image is shown in a large format and sends the value to (ajax_items.php) again which shows quantity and all detail information about the product.

    My problem is that when I search for a size and only one product is found, I need to display automatically (without clicking over the thumbnail) the picture product in a large format because I think it's not a good practice to show only one thumbnail image and when you click it displaying its large format. This is valid when there are multiple thumbnail images. What value should I return to the jquery function to display the image in a large format as soon as one pic color is found?
    I don't know how to do this using jquery.


    This is the jquery script I am using:

    Code:
    <script type="text/javascript">
    
    $(document).ready(function(){
    	$(".thumb div").hover(function(){
    		var largePath = $(this).attr("d");
    		$("#thumbLarge").attr({ src: largePath });
    	});
    	
    });
    </script>

    This is my HTML CODE which displays the picture in a large format:

    Code:
    <div align="center"><img id="thumbLarge" src="images/<%=imagen("img_name")%>" /></div>
    This is the HTML CODE shown after the size is sent to the (ajax_items.php) file and more than one value is found:

    Code:
    <li><a href="#" onclick="getcant(1)"><div d="images/image1.jpg")><img src="images/image1.jpg"></div></a></li>
    <li><a href="#" onclick="getcant(2)"><div d="images/image2.jpg")><img src="images/image2.jpg"></div></a></li>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,290
    Thanks
    23
    Thanked 611 Times in 610 Posts
    It just sounds to me that the problem your having lies with the database search your using. It appears to be returning one result and not all that match the criteria. Searching a database would be another section of this forum.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    My problem is to modify the jquery script

    Thanks sunfighter but I can return any value from my php file and database. I can return the whole path and name of any picture if I want.

    The problem is that the jquery script I am using is able only to change the large image when you click over the thumbnails. I want to modify that script or create a new one to accept the returned value and display the large image automatically (without clicking). The returned value could be the path and image name.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •