onclick event on table data (td)

Discussion in 'Javascript' started by Cylix, Jul 4, 2006.

  1. Cylix

    Cylix Guest

    In my javascript,
    var col = document.createElement('td');
    col.onclick=showContent;
    ....
    ....

    function showContent(msg) {
    alert(msg);
    }

    How can I pass the msg variable to the showContent function?
    Thank you.
     
    Cylix, Jul 4, 2006
    #1
    1. Advertising

  2. Cylix

    RobG Guest

    Cylix wrote:
    > In my javascript,
    > var col = document.createElement('td');
    > col.onclick=showContent;
    > ...
    > ...
    >
    > function showContent(msg) {
    > alert(msg);
    > }
    >
    > How can I pass the msg variable to the showContent function?
    > Thank you.


    col.onclick = function(){ showContent('the message'); }


    --
    Rob
     
    RobG, Jul 4, 2006
    #2
    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.
Similar Threads
  1. JerryG
    Replies:
    0
    Views:
    427
    JerryG
    Dec 20, 2005
  2. Rio
    Replies:
    4
    Views:
    1,199
  3. bob
    Replies:
    3
    Views:
    188
  4. Replies:
    2
    Views:
    259
  5. Michael_R_Banks

    onclick event in DOM table

    Michael_R_Banks, Feb 16, 2007, in forum: Javascript
    Replies:
    2
    Views:
    104
    Une BĂ©vue
    Feb 17, 2007
Loading...

Share This Page