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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Floating Cart Code/Script Problem

    Hello All,

    So, I have a website with a floating cart and it loads fine and works almost flawlessly lol. However, when a person has a bunch of items in their cart, and they want to minimize it for the rest of their browsing experience, every time a new page loads, or a refresh happens, the floating cart un-minimizes and expands out fully again displaying all the items.

    This can become very annoying during the shopping experience when you have a bunch of items loading and just taking up space in the browser. Therefore, I am wondering if their is some html or script that would save the minimizing in the floating cart, and carry it over to the next page, and the rest of the browsing on site?

    Thank you for any suggestions/help. I am new to HTML and script writing, but I am eager to learn. Hopefully in the future, I won't be paying for little changes like this every time I need one.

  • #2
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here is the javascript


    Code:
    <script type="text/JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>

    And here is the floating cart

    Code:
    <!--Start Floating Cart-->
    	<div id="dhtmlgoodies_q1" class="dhtmlgoodies_question">
    		<table width="100%" border="0" cellpadding="0" cellspacing="0">
    			<tr>
    				<td  class="itemsincart" id="numberofitem" valign="middle" align="left" height="22">Items in your Cart: <span>0</span></td>
    				<td  valign="middle" align="left" style="padding-right:3px;"><a onClick="myshowhide();"><img src="http://site.dlawlesshardware.com/ystore/images/plus-sign-img.jpg" id="showhide" border="0"></a></td>
    			</tr>
    		</table>
    	</div>
    	<div style="display: none; height: 1px; visibility: visible;" id="dhtmlgoodies_a1" class="dhtmlgoodies_answer">
    		<div id="dhtmlgoodies_ac1" class="dhtmlgoodies_answer_content">
    			<table width="176" align="center" border="0" cellpadding="0" cellspacing="0">
    			</tr>
       <tr>
        <td align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td  class="rgt-ysc-link" valign="middle" align="left" style="line-height:normal">
    <!--Floating Cart Code-->
    <table width="150" border="0" cellspacing="0" align="center" cellpadding="0">
      </tr>
       <tr>
    
        <td align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td id="viewitem"  class="view-items" valign="middle" align="center">Your shopping cart is empty.</td>
      </tr>
    
    </table>
    </td>
      </tr>
     </table>
    <script type="text/javascript" src="http://lib.store.yahoo.net/lib/dlawlesshardware/cookies.js"></script>
    <script type="text/javascript" src="http://lib.store.yahoo.net/lib/dlawlesshardware/writeCart.js"></script>
    <!--Floating Cart Code-->
    </td>
      </tr>
    </table></td>
      </tr>
     </table>
     </div>
     </div>
    <table width="153" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                              <td class="green-bg-txt" valign="top" align="left">Sub Total: <span id="cartitemtotal" class="white-txt">$00.00</span></td>
                            </tr>
                            <tr>
                              <td class="cart-links" valign="top" align="left" bgcolor="#FFFFFF"><a href="http://order.store.yahoo.net/cgi-bin/wg-order?catalog=dlawlesshardware" onclick="pageTracker._link('http://order.store.yahoo.net/cgi-bin/wg-order?catalog=dlawlesshardware',true);"><u>View Cart</u></a> <span>&nbsp;</span> <a href="https://us-dc1-order.store.yahoo.net/dlawlesshardware/ymix/MetaController.html?ysco_key_event_id=1&ysco_key_store_id=dlawlesshardware&sectionId=ysco.ship-bill"><u>Checkout</u></a></td>
                            </tr>
                           <tr>
                          <td valign="top" align="left"><img src="images/spacer.gif" alt="" class="lft-float" width="1" border="0" height="2"></td>
                        </tr>
                           <tr>
                             <td class="rgt-blue-bg-txt" id="shippingmessage" valign="top" align="center"> 						</td>
                           </tr>
    </table>
    
    
    
    
    
    
    <!--End of Start Floating Cart-->
    I think part of the problem is I cannot find any mmshowhide function in the javascript. I need to be able to save a cooke and recall it, but I'm in way over my head here. Thanks to anyone who even takes a look, lol.
    Last edited by dlaw13; 12-23-2010 at 10:19 PM. Reason: Added Full Floating Cart Code

  • #3
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Try using a cookie to store a '1' if the cart is open and a '0' if the cart in minimized this way on page load if the functions then check the cookie number if it is set and act accordingly to what number has been set in the cookie.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #4
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    So I need to create another function in the javascript to create/read this cookie? With an outline similar to this? And how would I sync it up to the showhide shopping cart image button? This might be too much for me to handle...

    Code:
    function createCookie(name,value,days) {
    	if (days) {
    		var date = new Date();
    		date.setTime(date.getTime()+(days*24*60*60*1000));
    		var expires = "; expires="+date.toGMTString();
    	}
    	else var expires = "";
    	document.cookie = name+"="+value+expires+"; path=/";
    }
    
    function readCookie(name) {
    	var nameEQ = name + "=";
    	var ca = document.cookie.split(';');
    	for(var i=0;i < ca.length;i++) {
    		var c = ca[i];
    		while (c.charAt(0)==' ') c = c.substring(1,c.length);
    		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

  • #5
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Basicly have an onclick command on what ever the user clicks to minimize the cart and also on the button to un-minimize it, and have this function write to the cookie with 1 or 0 so the button to minimize it would set a 0 and the button to un-minimize it would set a 1.

    Then get the current functions that display the cart to read this cookie so if the cookie isn't set or the number inside the cookie equals 0 hide the cart and if the number inside the cookie equals 1 show the cart.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #6
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yeah, this is too much for me. I was hoping I could find some code to copy and paste in the javascript, or beside the cart minimize/maximize button. I need to buy some books on java, scripts, html, etc. and start learning in my free time.

    I understand what your saying and the concept behind it, but I can't write that myself. Thank you for the help.

  • #7
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Quote Originally Posted by dlaw13 View Post
    Yeah, this is too much for me. I was hoping I could find some code to copy and paste in the javascript, or beside the cart minimize/maximize button. I need to buy some books on java, scripts, html, etc. and start learning in my free time.

    I understand what your saying and the concept behind it, but I can't write that myself. Thank you for the help.
    I will see what I can do to help you out but it will have to been in a bit as I am just doing something right now.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #8
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I went ahead and added all of the floating cart code to the original post. I'm not in any hurry, so getting back to me in a couple days or whatever would be awesome.

    I appreciate the help, you are going above and beyond in my book.

    Thanks

  • #9
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Ignore my PM to you I found your problem... Add this to the header of your site just above the end head tag.

    Code:
    window.onload=initShowHideDivs;
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #10
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I tried pasting that in the head tags, but it didn't seem to change anything. Let me know if you have anything else up your sleeve.

    Thanks

  • #11
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    I had a look at your source code and I don't see it anywhere???
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #12
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes, that's weird, I don't know why its not showing up in the source. My site is a Yahoo Store, so I placed the code in the head tags section under variables. I published and it should have added it. I'm investigating....

  • #13
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    <window.onload=initShowHideDivs;> Pasting it like that in another head tags section on y store now....problem is I can't just pull up the code and past it right beside the /head b/c I'm ystore working with rtml and a bunch of boxes that place code for me.
    Last edited by dlaw13; 12-24-2010 at 05:50 PM.

  • #14
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Paste it just before the closing head tag i.e. </head>.

    EDIT: You may have to put this though.

    Code:
    window.onload = (function(){
      initShowHideDivs();
      fillup();
    });
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #15
    New Coder
    Join Date
    Dec 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok, its not right beside the /head, but you can see it in there now. I'm going to try the new one you just gave me, other one didnt seem to do it.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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