www.webdeveloper.com
Results 1 to 6 of 6

Thread: Floating Cart Code/Script Problem

  1. #1
    Join Date
    Dec 2010
    Posts
    4

    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. #2
    Join Date
    Mar 2007
    Posts
    946
    You could set a cookie with javascript or a server side language. Then on a page reload or going to the next page check for the cookie and determine if the cart should be shown or not.
    "Hippies.They're everywhere. They wanna save the earth, but all they do is smoke pot and smell bad."-Cartman

  3. #3
    Join Date
    Dec 2010
    Posts
    4
    Thanks for the suggestion Skywalker. When it comes to JavaScripts or SS language though, I am only a padawon. Is there anywhere I can learn how to write this or even better, just copy and paste something into the rest of my javascripts and code?

  4. #4
    Join Date
    May 2006
    Posts
    9
    I think we would need to be able to see the source of the Javascript
    in order to know what to try and save.

    You could have a little look at this i stumbled across.
    http://www.sitepoint.com/forums/showthread.php?t=255633

    In theory its the same sort of principle, ,
    so a little editing here and there, you should be able to get it to work.

  5. #5
    Join Date
    Dec 2010
    Posts
    4
    HTML Code:
    <!--Start Floating Cart-->
    <div id="dhtmlgoodies_q1" class="dhtmlgoodies_question">
    <table width="100&#37;" 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;">[B]<a onClick="myshowhide();"><img src="http://site.dlawlesshardware.com/ystore/images/plus-sign-img.jpg" id="showhide" border="0"></a>[/B]</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">

    And then here is the javascript for the page

    HTML 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>
    Last edited by dlaw13; 12-23-2010 at 10:17 AM. Reason: HTML correction

  6. #6
    Join Date
    Dec 2010
    Posts
    4
    Thanks for the link Dave, I am studying it to see if I can figure it out, but I am a novice so this will be a tall task.

    I think part of the problem is I cannot find any mmshowhide function in the javascript.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles