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 23
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post

    Struggling with arrays

    Ok, I'm struggling with setting up an array to randomly select what to be shown in a scrolling pop up that looks like an im.

    Here's the working script I have now, just without the arrays:
    PHP Code:
    HEADER CODE:
    <
    LINK REL=StyleSheet HREF="scrolling_popup.css" TYPE="text/css">
        <
    script type="text/javascript" language="javascript" src="scrolling_popup.js"></script>
        <script type="text/javascript" >

            var html_code = '<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im.jpg" width="62" height="77"></td><td valign="top">Hey we live close to each other.<br>U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';

            buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);

        </script> 
    And this is the other part of the script that is placed in the footer:
    PHP Code:
    <script type="text/javascript" >
            
    setTimeout("ShowTheBox(false, rightSide, bottomCorner, bottopUp)"10000);
        
    </script> 
    Now I've tried several variations using similar code to this:
    PHP Code:
    Header script:
    <
    LINK REL=StyleSheet HREF="scrolling_popup.css" TYPE="text/css">
        <
    script type="text/javascript" language="javascript" src="scrolling_popup.js"></script>
        <script type="text/javascript" >
            
            var array=new Array()
            array[0]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im.jpg" width="62" height="77"></td><td valign="top">Hey we live close to each other.<br>U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            array[1]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im2.jpg" width="62" height="77"></td><td valign="top">Hey I live close to u!<br>R U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            array[2]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im3.jpg" width="62" height="77"></td><td valign="top">U don't live too far from me!<br>Wanna hook up sometime?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            function switch(num){
            var html_code = array[num]
            }
            Math.random(array.length)
                 buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);

        </script> 
    Please help

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,688
    Thanks
    80
    Thanked 4,650 Times in 4,612 Posts
    Ummm....

    Where, pray tell, is ShowTheBox( )???

    And you can't pass named value to a function invoked via setTimeout unless they are global variables on the page.

    And for that matter, where are all those values you are passing to ShowTheBox( ) supposed to be coming from?

    And this code makes no sense:
    Code:
    function switch(num){
            var html_code = array[num]
            }
            Math.random(array.length)
    (1) switch( ) is a keyword in JavaScript
    (2) you are assigning the value of one of the array elements to the variable html_code, but because that variable is defined local to that function, it just gets tossed in the garbage when the function terminates on the next line.
    (3) Okay, you are generating some sort of random number. But you don't assign it to anything or do anything with it. Oh...and Math.random() does *NOT* take an argument.

    *************

    Ignoring the stuff in your footer that doesn't seem at all related to the rest of this, I *think* that all you need is this:

    Code:
    <script type="text/javascript">        
    
    array[0]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im.jpg" width="62" height="77"></td><td valign="top">Hey we live close to each other.<br>U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
    array[1]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im2.jpg" width="62" height="77"></td><td valign="top">Hey I live close to u!<br>R U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
    array[2]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im3.jpg" width="62" height="77"></td><td valign="top">U don't live too far from me!<br>Wanna hook up sometime?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
           
    var html_code = array[ Math.floor( array.length * Math.random() ) ];
    buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);
    
    </script>

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Where, pray tell, is ShowTheBox( )???
    Answer: src="scrolling_popup.js"
    Code:
    // float directions
    var leftRight = 1;
    var rightLeft = 2;
    var topDown = 3;
    var bottopUp = 4;
    
    // side
    var leftSide = 1;
    var rightSide = 2;
    
    // position
    var topCorner = 1;
    var bottomCorner = 2;
    
    // default title
    var _title = 'Put here your title';
    
    // default width
    var popupWidth = 210;
    var popupHeight = 81;
    
    var only_once_per_browser = false;
    
    var ns4 = document.layers;
    var ie4 = document.all;
    var ns6 = document.getElementById&&!document.all;
    var crossobj;
    
    function getCrossObj()
    {
        var contentDiv;
        var titleDiv;
        
        if (ns4)
        {
            crossobj = document.layers.postit;
            contentDiv = document.layers.postit_content;
            titleDiv = document.layers.postit_title;
        }
        else if (ie4||ns6)
        {
            crossobj = ns6? document.getElementById("postit") : document.all.postit;
            contentDiv = ns6? document.getElementById("postit_content") : document.all.postit_content;
            titleDiv = ns6? document.getElementById("postit_title") : document.all.postit_title;
        }   
        crossobj.style.width = popupWidth + 'px';
        crossobj.style.height = popupHeight + 'px';
        
        // adjust the size of the div "content"
        contentDiv.style.width = (popupWidth-8) + 'px';
        contentDiv.style.height = (popupHeight-26) + 'px';
        
        // adjust the width of the div "title"
        titleDiv.style.width = (popupWidth-8) + 'px';
        
    }
    
    //
    //  buildPopup_Frame
    //  passing it the url of the frame to display inside
    //
    function buildPopup_Frame(width, height, title, framesrc)
    {
        if (width)
            popupWidth = width;
           
        if (height)
            popupHeight = height;
            
        if (title)
            _title = title
        
    
        document.write('<div id="postit" class="postit" >');
    
        document.write('<div id="postit_title" class="title"><b>' + _title + ' <span class="spantitle"><img src="close.gif" border="0" title="Close" align="right" WIDTH="11" HEIGHT="11" onclick="closeit()">&nbsp;</b></span></div>');
        document.write('<div id="postit_content" class="content">'); 
    
        document.write('<iframe src="' + framesrc + '" width="100%" height="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" bordercolor="#000000"></iframe>');
    
        document.write('</div></div>');
        
        getCrossObj();
    }
    
    //
    //  buildPopup_HtmlCode
    //  build popup passing it the html code to put inside
    //
    function buildPopup_HtmlCode(width, height, title, htmlCode)
    {
        if (width)
            popupWidth = width;
           
        if (height)
            popupHeight = height;
    
        if (title)
            _title = title
    
        document.write('<div id="postit" class="postit">');
    
        document.write('<div id="postit_title" class="title"><b>' + _title + ' <span class="spantitle"><img src="close.gif" border="0" title="Close" align="right" WIDTH="11" HEIGHT="11" onclick="closeit()">&nbsp;</b></span></div>');
        document.write('<div id="postit_content" class="content">'); 
    
        document.write(htmlCode);				
    
        document.write('</div></div>');
    
        getCrossObj();
    }
    
    //
    //  closeit
    //
    function closeit()
    {
        if (ie4||ns6)
            crossobj.style.visibility="hidden";
        else if (ns4)
            crossobj.visibility="hide";
    }
    
    //
    //  get_cookie
    //
    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;
    }
    
    //
    // check the cookie
    //
    function showOrNot(direction)
    {
        var showit = false;
        
        if (get_cookie('postTheBoxDisplay')=='')
        {
            showit = true;
            document.cookie = "postTheBoxDisplay=yes";
        }
        return showit;
    }
    
    //
    //  showItRight
    //
    function showIt(direction)
    {
        var steps;
        
        steps = Math.floor(popupHeight / 4)+5;
      
        
        if (ie4||ns6)
        {
            crossobj.style.visibility = "visible";
            if ((direction == rightLeft) || (direction == leftRight))
                flyTheBox(direction, 0, popupWidth , steps, 1000);
            else 
                flyTheBox(direction, 0, popupHeight , steps, 1000);
        }
        else if (ns4)
            crossobj.visibility = "show";
    }
    
    //
    //  flyTheBox
    //
    function flyTheBox(direction, start, end, steps, msec, counter)
    {
    	if(!counter)
    		counter = 1;
    
    	var tmp;
    
    	if(start < end)
    	{
    	    if (direction == rightLeft)
    	        crossobj.style.width = end / steps * counter + 'px'; 
    	    else if (direction == bottopUp)
    	        crossobj.style.height = end / steps * counter + 'px'; 
    	    else if (direction == topDown)
    	        crossobj.style.top = ((end / steps * counter) - popupHeight) + 'px'; 
            else if (direction == leftRight)
    	        crossobj.style.left = (end / steps * counter)-popupWidth + 'px'; 
    	        
        }
    	else 
    	{ 
    
    	    tmp=steps -	counter; 
    	    if (direction == rightLeft)
    	        crossobj.style.width = start / steps * tmp + 'px'; 
    	    else if (direction == bottopUp)
    	        crossobj.style.height = start / steps * tmp + 'px'; 
    	    else if (direction == topDown)
    	        crossobj.style.top = ((end / steps * counter) - popupHeight) + 'px'; 
    
    	} 
    	if(counter != steps) 
    	{ 
    	    counter++; 
    	    flyTheBox_timer=setTimeout('flyTheBox('+ direction + ',' + start + ','+ end + ',' + steps + ',' + msec + ', '+ counter + ')', msec/steps); 
    	} 
    	else 
    	{ 
    	    if(start > end)
    			crossobj.style.display = 'none';
    	}
    }
    
    
    //
    // ShowTheBox
    //
    function ShowTheBox(only_once, side, corner, direction)
    {
        if (side == leftSide)
        {
            if (direction == rightLeft)
                return;
            crossobj.style.left = '1px';
        }
        else
        {
            if (direction == leftRight)
                return;
    	    crossobj.style.right = '1px'; 
        }
    
        if ((corner == topCorner) && (direction == bottopUp))
            return;
    
        if ((corner == bottomCorner) && (direction == topDown))
            return;
            
        if ( (direction == topDown) && (corner == topCorner) )
            crossobj.style.top = '-' + popupHeight + 'px';    
        else if ( ((direction == rightLeft)||(direction == leftRight)) && (corner == topCorner) )
            crossobj.style.top = '1px';
        else if (corner == bottomCorner)
            crossobj.style.bottom = '2px';
    
        if (only_once)
            only_once_per_browser = only_once;
      
        if (only_once_per_browser)
        {
            // verify the presence of a cookie
    	    if (showOrNot())
    	        showIt(direction);
        }
        else
    	    setTimeout("showIt("+ direction + ")",1030);
    }
    Does that make any more sense?
    Last edited by sfraise; 03-13-2009 at 06:08 AM.

  • #4
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    this will do it I think

    function switch(){
    var num= Math.random(array.length)
    var html_code = array[num]
    }


    then just call switch

  • #5
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    Code:
     <script type="text/javascript" >
            
            var array=new Array()
            array[0]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im.jpg" width="62" height="77"></td><td valign="top">Hey we live close to each other.<br>U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            array[1]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im2.jpg" width="62" height="77"></td><td valign="top">Hey I live close to u!<br>R U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            array[2]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im3.jpg" width="62" height="77"></td><td valign="top">U don't live too far from me!<br>Wanna hook up sometime?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            function switch(){
    var num=  Math.random(array.length)
            var html_code = array[num]
     buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);
            }
          
                
    
        </script>  
    <body onload="switch()">

  • #6
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Thanks for all the help, but still not getting it.
    I've tried:
    Code:
    Head:
    <LINK REL=StyleSheet HREF="scrolling_popup.css" TYPE="text/css">
        <script type="text/javascript" language="javascript" src="scrolling_popup.js"></script>
        <script type="text/javascript" >
          var array=new Array()
            array[0]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im.jpg" width="62" height="77"></td><td valign="top">Hey we live close to each other.<br>U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            array[1]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im2.jpg" width="62" height="77"></td><td valign="top">Hey I live close to u!<br>R U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
            array[2]='<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im3.jpg" width="62" height="77"></td><td valign="top">U don't live too far from me!<br>Wanna hook up sometime?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
    function switch(){
    var num= Math.random(array.length)
    var html_code = array[num]
            buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);
    }
        </script>
    
    Footer:
    <script type="text/javascript" >
            onLoad="switch()";
    setTimeout("ShowTheBox(false, rightSide, bottomCorner, bottopUp)", 30000);
    </script>
    Still no luck.

  • #7
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    no, I'm sorry, it doesn't work. I have no idea why. I've used the exact same function before many many times. There's a problem with the way you're passing the html_code or something. isn't there a working example of the popup you can show us? I did notice you were missing the ends of the table tags and you put a ' in the word don't, which is a problem

  • #8
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Yeah, I have this working fine at www.oohya.net, it will scroll up at the bottom right of the page after 30 seconds.
    Using the following code:
    Header
    Code:
    <LINK REL=StyleSheet HREF="scrolling_popup.css" TYPE="text/css">
        <script type="text/javascript" language="javascript" src="scrolling_popup.js"></script>
        <script type="text/javascript" >
    
            var html_code = '<table border="0" width="100%"<tr><td valign="top"><img src="http://www.oohya.net/im.jpg" width="62" height="77"></td><td valign="top">Hey we live close to each other.<br>U Single?<br><br><a href="http://www.oohya.org" target="_blank">Reply</a></td></tr></table>';
    
            buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);
    
        </script>
    Footer
    Code:
    <script type="text/javascript" >
            //ShowTheBox(false, rightSide, bottomCorner, rightLeft);
            setTimeout("ShowTheBox(false, rightSide, bottomCorner, bottopUp)", 30000);
            //ShowTheBox(false, rightSide, topCorner, topDown);
            //ShowTheBox(false, rightSide, topCorner, rightLeft);
    
            //ShowTheBox(false, leftSide, bottomCorner, leftRight);
            //ShowTheBox(false, leftSide, bottomCorner, bottopUp);
            //ShowTheBox(false, leftSide, topCorner, topDown);
            //ShowTheBox(false, leftSide, topCorner, leftRight);
            //ShowTheBox(false, leftSide, topCorner, leftRight);
        </script>
    This of course just uses the one option.

    The scrolling_popup.js code is:
    Code:
    // float directions
    var leftRight = 1;
    var rightLeft = 2;
    var topDown = 3;
    var bottopUp = 4;
    
    // side
    var leftSide = 1;
    var rightSide = 2;
    
    // position
    var topCorner = 1;
    var bottomCorner = 2;
    
    // default title
    var _title = 'Put here your title';
    
    // default width
    var popupWidth = 210;
    var popupHeight = 81;
    
    var only_once_per_browser = false;
    
    var ns4 = document.layers;
    var ie4 = document.all;
    var ns6 = document.getElementById&&!document.all;
    var crossobj;
    
    function getCrossObj()
    {
        var contentDiv;
        var titleDiv;
        
        if (ns4)
        {
            crossobj = document.layers.postit;
            contentDiv = document.layers.postit_content;
            titleDiv = document.layers.postit_title;
        }
        else if (ie4||ns6)
        {
            crossobj = ns6? document.getElementById("postit") : document.all.postit;
            contentDiv = ns6? document.getElementById("postit_content") : document.all.postit_content;
            titleDiv = ns6? document.getElementById("postit_title") : document.all.postit_title;
        }   
        crossobj.style.width = popupWidth + 'px';
        crossobj.style.height = popupHeight + 'px';
        
        // adjust the size of the div "content"
        contentDiv.style.width = (popupWidth-8) + 'px';
        contentDiv.style.height = (popupHeight-26) + 'px';
        
        // adjust the width of the div "title"
        titleDiv.style.width = (popupWidth-8) + 'px';
        
    }
    
    //
    //  buildPopup_Frame
    //  passing it the url of the frame to display inside
    //
    function buildPopup_Frame(width, height, title, framesrc)
    {
        if (width)
            popupWidth = width;
           
        if (height)
            popupHeight = height;
            
        if (title)
            _title = title
        
    
        document.write('<div id="postit" class="postit" >');
    
        document.write('<div id="postit_title" class="title"><b>' + _title + ' <span class="spantitle"><img src="close.gif" border="0" title="Close" align="right" WIDTH="11" HEIGHT="11" onclick="closeit()">&nbsp;</b></span></div>');
        document.write('<div id="postit_content" class="content">'); 
    
        document.write('<iframe src="' + framesrc + '" width="100%" height="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" bordercolor="#000000"></iframe>');
    
        document.write('</div></div>');
        
        getCrossObj();
    }
    
    //
    //  buildPopup_HtmlCode
    //  build popup passing it the html code to put inside
    //
    function buildPopup_HtmlCode(width, height, title, htmlCode)
    {
        if (width)
            popupWidth = width;
           
        if (height)
            popupHeight = height;
    
        if (title)
            _title = title
    
        document.write('<div id="postit" class="postit">');
    
        document.write('<div id="postit_title" class="title"><b>' + _title + ' <span class="spantitle"><img src="close.gif" border="0" title="Close" align="right" WIDTH="11" HEIGHT="11" onclick="closeit()">&nbsp;</b></span></div>');
        document.write('<div id="postit_content" class="content">'); 
    
        document.write(htmlCode);				
    
        document.write('</div></div>');
    
        getCrossObj();
    }
    
    //
    //  closeit
    //
    function closeit()
    {
        if (ie4||ns6)
            crossobj.style.visibility="hidden";
        else if (ns4)
            crossobj.visibility="hide";
    }
    
    //
    //  get_cookie
    //
    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;
    }
    
    //
    // check the cookie
    //
    function showOrNot(direction)
    {
        var showit = false;
        
        if (get_cookie('postTheBoxDisplay')=='')
        {
            showit = true;
            document.cookie = "postTheBoxDisplay=yes";
        }
        return showit;
    }
    
    //
    //  showItRight
    //
    function showIt(direction)
    {
        var steps;
        
        steps = Math.floor(popupHeight / 4)+5;
      
        
        if (ie4||ns6)
        {
            crossobj.style.visibility = "visible";
            if ((direction == rightLeft) || (direction == leftRight))
                flyTheBox(direction, 0, popupWidth , steps, 1000);
            else 
                flyTheBox(direction, 0, popupHeight , steps, 1000);
        }
        else if (ns4)
            crossobj.visibility = "show";
    }
    
    //
    //  flyTheBox
    //
    function flyTheBox(direction, start, end, steps, msec, counter)
    {
    	if(!counter)
    		counter = 1;
    
    	var tmp;
    
    	if(start < end)
    	{
    	    if (direction == rightLeft)
    	        crossobj.style.width = end / steps * counter + 'px'; 
    	    else if (direction == bottopUp)
    	        crossobj.style.height = end / steps * counter + 'px'; 
    	    else if (direction == topDown)
    	        crossobj.style.top = ((end / steps * counter) - popupHeight) + 'px'; 
            else if (direction == leftRight)
    	        crossobj.style.left = (end / steps * counter)-popupWidth + 'px'; 
    	        
        }
    	else 
    	{ 
    
    	    tmp=steps -	counter; 
    	    if (direction == rightLeft)
    	        crossobj.style.width = start / steps * tmp + 'px'; 
    	    else if (direction == bottopUp)
    	        crossobj.style.height = start / steps * tmp + 'px'; 
    	    else if (direction == topDown)
    	        crossobj.style.top = ((end / steps * counter) - popupHeight) + 'px'; 
    
    	} 
    	if(counter != steps) 
    	{ 
    	    counter++; 
    	    flyTheBox_timer=setTimeout('flyTheBox('+ direction + ',' + start + ','+ end + ',' + steps + ',' + msec + ', '+ counter + ')', msec/steps); 
    	} 
    	else 
    	{ 
    	    if(start > end)
    			crossobj.style.display = 'none';
    	}
    }
    
    
    //
    // ShowTheBox
    //
    function ShowTheBox(only_once, side, corner, direction)
    {
        if (side == leftSide)
        {
            if (direction == rightLeft)
                return;
            crossobj.style.left = '1px';
        }
        else
        {
            if (direction == leftRight)
                return;
    	    crossobj.style.right = '1px'; 
        }
    
        if ((corner == topCorner) && (direction == bottopUp))
            return;
    
        if ((corner == bottomCorner) && (direction == topDown))
            return;
            
        if ( (direction == topDown) && (corner == topCorner) )
            crossobj.style.top = '-' + popupHeight + 'px';    
        else if ( ((direction == rightLeft)||(direction == leftRight)) && (corner == topCorner) )
            crossobj.style.top = '1px';
        else if (corner == bottomCorner)
            crossobj.style.bottom = '2px';
    
        if (only_once)
            only_once_per_browser = only_once;
      
        if (only_once_per_browser)
        {
            // verify the presence of a cookie
    	    if (showOrNot())
    	        showIt(direction);
        }
        else
    	    setTimeout("showIt("+ direction + ")",1030);
    }
    Last edited by sfraise; 03-13-2009 at 05:32 AM.

  • #9
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    here's a working random script. Notice the double quotes ", not single quotes ' encapsulating the html output. perhaps this is your problem.

    You might have to leave out the double quotes and use single quotes for images and styles


    I put these images into this random script to show you.
    this is from codelifter.com, my favorite resource site. His examples are concise and easy to follow.
    Code:
    <script language="JavaScript">
    // ==============================================
    // Copyright 2004 by CodeLifter.com
    // Free for all; but please leave in this header.
    // ==============================================
    
    var Quotation=new Array() // do not change this!
    
    // Set up the quotations to be shown, below.
    // To add more quotations, continue with the
    // pattern, adding to the array.  Remember
    // to increment the Quotation[x] index!
    
    Quotation[0] = "Time is of the essence! Comb your hair.<img src='Image.jpg'>";
    Quotation[1] = "Sanity is a golden apple with no shoelaces.<img src='Image.jpg'>";
    Quotation[2] = "Repent! The end is coming, $9.95 at Amazon.<img src='Image.jpg'>";
    Quotation[3] = "Honesty blurts where deception sneezes.<img src='Image.jpg'>";
    Quotation[4] = "Pastry satisfies where art is unavailable.<img src='Image.jpg'>";
    Quotation[5] = "Delete not, lest you, too, be deleted.<img src='Image.jpg'>";
    Quotation[6] = "O! Youth! What a pain in the backside.<img src='Image.jpg'>";
    Quotation[7] = "Wishes are like goldfish with propellors.<img src='Image.jpg'>";
    Quotation[8] = "Love the river's \"beauty\", but live on a hill.<img src='Image.jpg'>";
    Quotation[9] = "Invention is the mother of too many useless toys.<img src='Image.jpg'>";
    
    // ======================================
    // Do not change anything below this line
    // ======================================
    var Q = Quotation.length;
    var whichQuotation=Math.round(Math.random()*(Q-1));
    function showQuotation(){document.write(Quotation[whichQuotation]);}
    showQuotation();
    </script>

  • #10
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Took the ' out of don't and changed to double quotes but still no luck.

    Maybe someone with fresh eyes will find it and see something we're missing.

  • #11
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    Hey, I got your script to at least get some output

    Code:
    <script type="text/javascript" >
            
           
    var array=new Array();
            array[0]="<table border='0' width='100%'><tr><td valign='top'><img src='http://www.oohya.net/im.jpg' width='62' height='77'></td><td valign='top'>Hey we live close to each other.<br>U Single?<br><br><a href='http://www.oohya.org' target='_blank'>Reply</a></td></tr></table>";
            array[1]="2";
            array[2]="3";
     var num=Math.random()*(array.length)      
    
    
            var html_code = array[num];
    buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);
    
           
          
                 
    
        </script>
    but unfortunately, i don't think html_code is being fed the right stuff. I tried to give it just simple text and it wouldn't come up. The array won't even show a value using an alert. I think you need to start over with what the last value in build popup is supposed to be. The hotlips stuff prints out, but I tried using single quotes and some text, but it didn't show up.

  • #12
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    BTW, I never saw the popup scroll up in the example you posted above. I'm using firefox

  • #13
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Are you using the scrolling_popup.js file along with it?
    <LINK REL=StyleSheet HREF="scrolling_popup.css" TYPE="text/css">
    <script type="text/javascript" language="javascript" src="scrolling_popup.js"></script>
    <script type="text/javascript" >
    Last edited by sfraise; 03-13-2009 at 06:07 AM.

  • #14
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    I might have been working on the script at the time.
    It should be working now, does for me anyway and I'm using firefox.
    It's on a 30 second delay.

  • #15
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    I added the code you just gave and see what you mean.
    The pop up scrolls up and shows the title and stuff but where the html should be it says undefined.
    It works fine though when I just use the one option without an array.

    Ok, so then I changed the
    Code:
    buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', html_code);
    To:
    Code:
    buildPopup_HtmlCode(200, 140, 'IM from: sweetlips69  F/23', array);
    When it popped up it had both options in the one box.
    Hey, it's closer anyway lol.
    Basically this is telling me that we're not defining the var html_code correctly, but shouldn't that be what the var html_code = array[num] is doing?
    Last edited by sfraise; 03-13-2009 at 07:42 AM.


  •  
    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
    •