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. Advertising

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.

Share This Page