User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 373,915 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,631 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

add onclick event programmatically

Join Date: May 2005
Posts: 3
Reputation: zaki is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zaki zaki is offline Offline
Newbie Poster

Help add onclick event programmatically

  #1  
May 10th, 2005
I have a code that I call from Button_click event.
The code adds a new row to the table and attempts
to add onclick element to every td element in the new row.
Somehow, onclick does not work.
Any help is appreciated.
Here is the code:
function insRow()
{
var x = document.getElementById('Table1').insertRow(1);
for(i=0;i<4;i++)
{
var td = document.createElement('td');
td.innerHTML = 'NewItem';
td.setAttribute('onclick', 'alert("blabla")');
x.appendChild(td);
}
}
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 5:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC