Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Jul 2003
    Posts
    3
    Member #
    2151
    OK I have a script that opens random popups, what I would like to know is is it possible to include a var in the random list so if chosen would select from another list?

    i.e. I have a list of 10 popups 8 are sites on list A while 2 direct the random code to select randomly from list B.

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Javascript, not Java. There's a massive difference...
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Junior Member
    Join Date
    Jul 2003
    Posts
    3
    Member #
    2151
    Sorry

    Sorry I said I was new to this, and I meant it, can you help me at all?

  5. #4
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    So, you want 80% of the popups to come from list A, and 20% from list B?
    List A has ListACount = 8 addresses, and List B has ListBCount = ??? addresses?
    And your website is www.savethekitties.org, and your popups direct the user to various registered charities :-) ?
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  6. #5
    Junior Member
    Join Date
    Jul 2003
    Posts
    3
    Member #
    2151
    basically

    The website is for a small cafe, and she wants list A to be small specials like 5% of your meal or a a free jar of homemade jam, ect. but list be she want to be big specials like buy one meal get one other free, etc.

    She also has not fully decided how many specials she wants done, but I want to code it so I can add new specials without having to change the math variable, I have already coded the first list so it does that, but I need help trying to figure out how to code in a second vairiable so it might go to a second list.

  7. #6
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    hmm...
    Code:
    <script language="JavaScript">
    function DoPopup() {
      var ListApc = 0.8; // PerCentage from List A
      var NrListA = 8;
      var NrListB = 1; //Change this to suit!
      var ListAPages = new Array("popup_dir/popa1.html","popup_dir/popa2.html", ...
         ,"popup_dir/popa8.html");
      var ListBPages = new Array("popup_dir/popb1.html");
      var PopupUrl = "";
      if (Math.random() < ListApc) //Choose from List A
        PopupUrl = ListAPages[Math.floor(NrListA*Math.random())];
      else
        PopupUrl = ListBPages[Math.floor(NrListB*Math.random())];
      window.open(PopupUrl ,"Special Offer","width=400,height=338,toolbar,location,directories,status,scrollbars,menubar,resizable,");
    }
    </script>
    • You need some code to invoke this function, like <body onload="DoPopup()">
    • After this is working, you need to add some cookie stuff to make sure the user can't just reload to get every single coupon.
    • If you keep standard names for the popup pages (popa1.html, popa2.html etc) you can probably do away with the ListAPages & B array as well.
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  8. #7
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    This should do it!

    Code:
    function DoPopup() {
      // Just like previous post
    }
    
    function get_cookie(Name) {
      var search = Name + "="
      var returnvalue = "";
      if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        if (offset != -1) { // if cookie exists
          offset += search.length
          // set index of beginning of value
          end = document.cookie.indexOf(";", offset);
          // set index of end of cookie value
          if (end == -1)
             end = document.cookie.length;
          returnvalue=unescape(document.cookie.substring(offset, end))
          }
       }
      return returnvalue;
    }
    
    function loadornot() {
      if (get_cookie('poppedup')=='') {
        DoPopup()
        document.cookie="poppedup=yes"
      }
    }
    
    loadornot()
    thx to http://javascriptkit.com/popwin/index.shtml
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:44 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com