#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Document.write a new array element by button


    Hi,

    I am a proper beginner so please bear with me. I have a webpage which prints out a random element from an array when the page loads and that works.

    What I would like is to have a button on my website which will document.write a random element from an array when I press it but without reloading the page. I can get it to work by calling the function which document.write a random element from the array but this prints out on a new webpage and everything else is gone...

    Can someone show me how I can do this?

    Thanks very much.
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    Welcome to DevShed, sitefinder.

    Can you post what you have at the moment?
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    Os

IMN logo majestic logo threadwatch logo seochat tools logo