Solved

row.onClick="alert()" when building table using javascript

Posted on 2004-10-26
987 Views
Last Modified: 2012-05-05
var row = table.insertRow(0);
row.className = "lb"
row.vAlign="top"
row.onClick="alert()"

i'm trying to modify a table and include an onClick event handler, as far as i can tell this should work

any ideas
0
Question by:steve_steele
    4 Comments
     
    LVL 6

    Expert Comment

    by:boblah
    Hi steve_steele,

    try

    row.onClick=function(){alert();}


    Cheers!
    0
     
    LVL 6

    Expert Comment

    by:boblah
    steve_steele,

    or, if you want to make use of the event arguments:

    row.onClick=function(e){alert();}
    0
     
    LVL 13

    Accepted Solution

    by:
    Just a suggestion:

    You should use the all-lowercase versions of the event handlers:

    row.onclick = function() {alert();}
    0
     

    Author Comment

    by:steve_steele
    that sorted it thank you very much
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: From Zero to Hero with Nodejs & MongoDB

    Interested in Node.js, but don't know where to start or how to learn it properly? Confused about how the MEAN stack pieces of MongoDB, Expressjs, Angularjs, and Nodejs fit together? Or how it's even possible to run JavaScript outside of the browser?

    This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    5 Experts available now in Live!

    Get 1:1 Help Now