Create input button with event

Discussion in 'Javascript' started by quoclinh, Jun 22, 2007.

  1. quoclinh

    quoclinh Guest

    Hi,

    I'd like to create an input button with a click event calling a
    javascript function. pretty basic. I just can't figure out how to
    wire the onclick event. this is what I have so far:

    function createButton(text, clickEvent)
    {
    var btn = document.createElement('input');
    btn.type = 'submit';
    btn.value = text;
    //How to code click event here?

    //How to set default css class?

    return btn;
    }

    Your help is much appreciated.

    Quoc Linh
     
    quoclinh, Jun 22, 2007
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    1,152
    Purvi T
    Oct 19, 2004
  2. jorge
    Replies:
    2
    Views:
    1,655
    jorge
    May 26, 2004
  3. Guy
    Replies:
    5
    Views:
    3,080
    brucie
    Dec 13, 2003
  4. jorge
    Replies:
    1
    Views:
    614
    Teemu Keiski
    May 28, 2004
  5. jorge
    Replies:
    0
    Views:
    499
    jorge
    May 25, 2004
  6. jorge
    Replies:
    0
    Views:
    466
    jorge
    May 25, 2004
  7. gotcha
    Replies:
    0
    Views:
    339
    gotcha
    Oct 24, 2003
  8. Ron Brennan
    Replies:
    5
    Views:
    640
    Dr John Stockton
    May 14, 2004
Loading...