Force 1 thumbnail by using javascript

Discussion in 'JavaScript' started by guod, Oct 19, 2010.

  1. #1
    We got our image view situation about 95% figure out, but need one last thing. How can we tell the image viewer to display 1 thumbnail, no matter the case?

    When a product only has one picture, as opposed to 2-4, there is no thumbnail associated with the main image. We would like to have one thumbnail appear no matter the case, as it fits in with page design. Anyone know how to edit the code to do this?

    Here is the javascript.

    <script language="javascript"><!--
    //thumbnail script
    var image1,image2,image3,image4,selectedimage;
    var imagemaxwidth, imagemaxheight
    
    imagemaxwidth=[image_medium_w];
    imagemaxheight=0;
    
    image1="[image1]";
    image2="[image2]";
    image3="[image3]";
    image4="[image4]";
    imagecaption1="[imagecaption1]";
    imagecaption2="[imagecaption2]";
    imagecaption3="[imagecaption3]";
    imagecaption4="[imagecaption4]";
    selectedimage='[image1]'; //pre load image1
    zoom_enable=[3dzoom_enabled]; //0 = zoomify | 1 = magiczoom
    
    function image_click(clicks)
    {
    if (document.getElementById('listing_main_image_link')!=undefined)
    {
    if (zoom_enable==1)
    {
    selectedimage=eval('image'+clicks);
    MagicZoomPlus.update('listing_main_image_link', selectedimage, 'thumbnail.asp?file=' + selectedimage + '&maxx='+imagemaxwidth+'&maxy='+imagemaxheight, 'show-title: false');
    changecontent("imagecaptiont",eval('imagecaption'+clicks));
    document.getElementById('listing_main_image_link').href=this.name;
    }else
    {
    
    selectedimage=eval('image'+clicks);
    document.getElementById('large').src='thumbnail.asp?file=' + selectedimage + '&maxx='+imagemaxwidth+'&maxy='+imagemaxheight;
    document.getElementById('listing_main_image_link').href='#';
    document.getElementById('listing_main_image_link').onclick=zoomify_popup;
    changecontent("imagecaptiont",eval('imagecaption'+clicks));
    }}
    }
    function zoomify_popup()
    {
    popupsimple('zoomify.asp?catalogid=[catalogid]&img=' + selectedimage ,500,500);
    }
    
    function check_stock(what,partnum)
    {
    var soption;
    var i;
    var product_availability='[availability]';
    var backordermode='[allowbackorder]';
    var avail_instock='[productAvailability-Instock]';
    var avail_outofstock='[productAvailability-Outofstock]';
    var avail_backorder='[productAvailability-Backorder]';
    var optionfound=0;
    
    if (inventoryarray[catalogid].length==0) //if there is no advanced options, don't look for stock
    {
    return true;
    }
    else
    {
    for(i=0;i<inventoryarray[catalogid].length;i++)
    {
    soption=inventoryarray[catalogid][i];
    field_array=soption.split("-");
    //Dynamic Part for advanced options
    if (typeof((idarray[catalogid])) != "undefined")
    {
    soptionid=idarray[catalogid][i];
    aoprice=aopricearray[catalogid][i];
    if (field_array[0]==partnum)
    {
    if (soptionid != '')
    changeid(soptionid);
    if (aoprice != '0')
    changeprice(aoprice);
    }
    }
    
    if ((field_array[0]==partnum))
    {
    changecontent("product_inventory",field_array[1]);
    if (eval(GetValue(what,"qty-0"))>field_array[1])
    {
    optionfound=optionfound+1;
    if (backordermode==1)
    {
    changecontent("availability",avail_backorder);
    return true;
    optionfound=optionfound+1;
    }
    else
    {
    changecontent("availability",avail_outofstock);
    alert("The options you selected are not currently available.");
    optionfound=optionfound+2;
    return false;
    }
    }
    
    }
    }
    
    if (optionfound==0)
    {
    changecontent("availability",product_availability);
    return true;
    }
    
    if (optionfound==1)
    {
    changecontent("availability",avail_instock);
    return true;
    }
    }
    }
    
    
    function add_wishlist()
    {
    document.add.action = "add_cart.asp?action=addWishList";
    document.add.submit();
    }
    
    function add_giftregistry()
    {
    document.add.action = "add_cart.asp?action=addGiftRegistry";
    document.add.submit();
    }
    
    function check_and_add(formx)
    {
    
    if (document.add.std_price==null)
    {
    document.add.submit();
    }
    else
    {
    var readytoadd=validateValues(formx,1)
    if (readytoadd==true)
    {
    document.add.submit();
    }
    }
    }
    
    // --></script> 
    Code (markup):
     
    guod, Oct 19, 2010 IP
  2. guod

    guod Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    bump..anyone have a solution?
     
    guod, Oct 21, 2010 IP