Results 1 to 10 of 10

Thread: Change Div on Refresh of page???

  1. #1
    Join Date
    May 2009
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Post Change Div on Refresh of page???

    Want to change the text in div on every refresh of the page. The text is not coming through database. The text is manually inserted.

    I am new to java script and i am unable to do it. Kindly help me. It is required urgently. And i am working on PHP page.

    Waiting for your replies....

    Thanks in advance......

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Is the text in the Div to be changed sequentially or randomly, ie you have text1, text2, text3, etc. If you have text1 currently displayed do you want text2 to be displayed on refresh or can it be either text2 or text3.

  3. #3
    Join Date
    May 2009
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    any way will do.... sequentially or randomly

  4. #4
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    This link is discussing something similar, with an example script: http://www.dynamicdrive.com/forums/s...ad.php?t=45102

    Also thiis is referring to quotes there should be no unreasonable limit to the amount of text attached to each variable.

    See if this points you in the right direction

  5. The Following User Says Thank You to forum_amnesiac For This Useful Post:

    dhawal.mhatre (05-21-2009)

  6. #5
    Join Date
    May 2009
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Post

    no friend...
    its not working on random function...

    i want it to change on refresh of page....

  7. #6
    Join Date
    May 2009
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Post

    i have JavaScript for refreshing images randomly.....

    Code:
    <head>
    
    <style type="text/css">
    div#container {
    width:320px; margin-left:10px; margin-top:5px;}
    img#random {
    width:320px;
    height:150px;
    }
    </style> 
    <script type="text/javascript">
    //<![CDATA[
    
    var images=new Array();
    images[0]="images/1.jpg";
    images[1]="images/2.jpg";
    images[2]="images/3.jpg";
    images[3]="images/4.jpg";
    images[4]="images/5.jpg";
    images[5]="images/6.jpg";
    
    function randomImage() {
    var i=Math.floor(Math.random()*images.length);
    document.getElementById("customerreviews").src=images[i];
    }
    onload=randomImage;
    //]]>
    </script>
    
    </head> 
    
    <body>
    <div id="container"><img id="random" src="" alt=""/></div> 
    </body>
    i try replacing images with text but its not working.....
    Last edited by Snookerman; 05-21-2009 at 08:04 AM. Reason: added [code] tags

  8. #7
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Try using the function listed on the link for random quotes.

    That should give different text on page refresh as well as when the page is opened if it is called inside your Div.

  9. The Following User Says Thank You to forum_amnesiac For This Useful Post:

    dhawal.mhatre (05-21-2009)

  10. #8
    Join Date
    May 2009
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question

    i didn't understand you. Which function you are talking about.

    please can you provide me with proper code

  11. #9
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Here is a fairly simple script for displaying random text/quotes

    Code:
    function write_quote() {
     
        var quotes = [
            'no animals were harmed while making this page',
            'made in ulm',
            'this page was handmade',
            'Get <a href="http://www.mozilla.org/products/firefox/">FireFox</a> :-)'
        ];
     
        var r = Math.round(Math.random() * (quotes.length-1));
     
        // write the quote
        document.write(quotes[r]);
     
        // or replace an HTML element:
        // document.getElementById("quote").innerHTML = quotes[r];
     
    }
    Here is a link to another way of doing this using an external js file
    http://wsabstract.com/script/script2...tequotes.shtml

  12. The Following User Says Thank You to forum_amnesiac For This Useful Post:

    dhawal.mhatre (05-23-2009)

  13. #10
    Join Date
    May 2009
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Thumbs up

    thanks a lot friend...
    its done

Bookmarks

Posting Permissions

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