Depressable Button Problem!

This is a discussion on Depressable Button Problem! within the C++ Programming forums, part of the General Programming Boards category; Hi there, I'm new to Javascript. Here's my problem: I've made a drepessable button but I want it to display ...

  1. #1
    WWright
    Guest

    Depressable Button Problem!

    Hi there, I'm new to Javascript. Here's my problem: I've made a drepessable button but I want it to display text on the same page each time I press it so I can use the button as many times as I want. If I use document.write it erases the button after the first click. How can I fix this?

    <head>
    <Script language="JavaScript">
    var malename = new Array(
    "Allen","Bob","Gerald")

    var lastname = new Array(
    "Adams","Bowden","Prichard")

    var r = 0;
    var i = 0;
    function RandomName()
    {
    r = Math.floor(Math.random() * lastname.length);
    i = Math.floor(Math.random() * malename.length);
    document.write(malename[i]+" "+lastname[r])
    }
    </head>

    <body>
    <a href="#" onMousedown="document.images['example'].src=img2.src"
    onClick="RandomName()" onMouseup="document.images['example'].src=img1.src">
    <img src="picture.gif" name="example" border=0>
    </body>

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    use code tage, then find a java board!

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    No, use a javascript board because javascript is very different from java.

  4. #4
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    no, use a...dangit, I can't think of anywhere better to go

  5. #5
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    (JavaScript != C++) && (Java != JavaScript)
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-06-2010, 12:42 AM
  2. elliptical button
    By geek@02 in forum Windows Programming
    Replies: 0
    Last Post: 11-21-2006, 02:15 AM
  3. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 06:20 AM
  4. Pressing a button works sometimes
    By johny145 in forum Windows Programming
    Replies: 14
    Last Post: 05-18-2005, 12:53 PM
  5. Window won't display on button command!?
    By psychopath in forum Windows Programming
    Replies: 6
    Last Post: 06-22-2004, 09:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21