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.
Results 1 to 5 of 5

Thread: Refresh a Div?

  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    86
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Refresh a Div?

    Heya!

    How can I refresh a div?

    I'd be having an image, and use onclick(), i'm guessing, but what code would I use?

    Cheers

    ~ David

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,692
    Thanks
    25
    Thanked 657 Times in 656 Posts
    http://www.w3schools.com/js/js_examples.asp

    Go to JavaScript Events

    click "Acting to the onclick event"

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    86
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    http://www.w3schools.com/js/js_examples.asp

    Go to JavaScript Events

    click "Acting to the onclick event"
    Cheers!

    How would I refresh it?

    Thanks

    ~ David

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,692
    Thanks
    25
    Thanked 657 Times in 656 Posts
    I just told you. Read what i sent.

    Where are you getting what is displayed in the div? Do you make it? Do you get it from outside source?

    Can you post code? Can you give link to your site?

  • Users who have thanked sunfighter for this post:

    mbarandao (05-30-2012)

  • #5
    Regular Coder
    Join Date
    Nov 2010
    Location
    Washington DC
    Posts
    341
    Thanks
    22
    Thanked 1 Time in 1 Post
    Very helpful! I've been looking for something like this. With a little a bit of modification on the example provided on http://www.w3schools.com/js/js_examples.asp, I am able to refresh a div.

    Thanks for the link!
    Mossa

    working code:

    PHP Code:
    <script type="text/javascript"> <!--using this code to refresh a div within pageadd this button to the form <button type="button" onclick="refresh()">refresh</button>-->
    function 
    refresh()
    {
    document.getElementById("toggleText3").innerHTML="<iframe id=\"accounting\" frameborder=0 scrolling=no width=100%  src=\"someplace.php\" height=\"300\" ></iframe>";
    }
    </script> 
    the iframe is within a <div>

    so on:
    PHP Code:
    <button type="button" onclick="refresh()"></button
    the div is refreshed!
    Last edited by mbarandao; 05-30-2012 at 06:12 PM. Reason: modified


  •  

    Posting Permissions

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