473,412 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Inserting events on cells generated by insertCell

Hi:

I've a problem with cells generated by insertCell, I need to add
"onclick" event something like this

html+='\t<td class='+ClassSelection+' id='+i+'-'+j
+' onclick='+this.GetName()+'.Select('+i+','+j+');'
+ this.GetName()+'.Draw(true);>'
+actual.Text+'</td>\n';*/

to generate something like:

<td class="class" id=1-3 onclick=main.Select(1-3);main.Draw(true);>
sometext </td>

with DOM I'm doing something like

var cell=row.insertCell(-1);
cell.innerHTML=actual.Text;
cell.className=ClassSelection;
cell.id=i+'-'+j;

and that works but I don't know how to do to generate the "onclick"
part.... Any help?

Apr 8 '07 #1
3 5476
and that works but I don't know how to do to generate the "onclick"
part.... Any help?
Answering my own question:

the trick is use setAttribute to the cell. Ex:
cell.setAttribute('onclick','alert(\'something\')' );

Apr 8 '07 #2
"manolopm" <ma******@gmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
Hi:

I've a problem with cells generated by insertCell, I need to add
"onclick" event something like this

html+='\t<td class='+ClassSelection+' id='+i+'-'+j
+' onclick='+this.GetName()+'.Select('+i+','+j+');'
+ this.GetName()+'.Draw(true);>'
+actual.Text+'</td>\n';*/

to generate something like:

<td class="class" id=1-3 onclick=main.Select(1-3);main.Draw(true);>
sometext </td>

with DOM I'm doing something like

var cell=row.insertCell(-1);
cell.innerHTML=actual.Text;
cell.className=ClassSelection;
cell.id=i+'-'+j;

and that works but I don't know how to do to generate the "onclick"
part.... Any help?
cell.onclick = function() { alert(this); }

-Lost
Apr 8 '07 #3
manolopm said the following on 4/8/2007 1:42 PM:
>and that works but I don't know how to do to generate the "onclick"
part.... Any help?

Answering my own question:

the trick is use setAttribute to the cell. Ex:
cell.setAttribute('onclick','alert(\'something\')' );
cell.onclick=function(){alert('something')}

Be vary wary with IE and setAttribute. It is a crap shoot as to whether
it works right or not.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rsd | last post by:
how do you specify the "colspan" attribut of a <td> cell when building the table/rows/cells dynamicly? ie: lets say we have the follwoing code: table = document.all; // header row tr1 =...
1
by: Eitan | last post by:
Hello, In a table element How can I insert cell in their order (A, B, C, D ...) on javascript runtime, but see the cells inserted from right to left. I am doing : myTable.row(0).insertCell(0) //...
6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
2
by: luca | last post by:
I'm trying to build a Server Control, it's a calendar to manage sellers appointments (don't answer me to use and custumize Calendar Control because unluckily it's not possible for this specific...
4
by: JezB | last post by:
I am dynamically creating WebControls and creating them on my page. Some of these are buttons, and I attach events to these buttons. The problem is these force a post-back, so I must regenerate all...
3
by: Mike | last post by:
Hi, I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-( namespace...
8
by: Stefan Mueller | last post by:
I'm really very confused. With the following code I can add rows/fields in frame 1 and 2. If I use IE, Mozilla or Opera the new rows/fields get added in ascending order. However, if I use Safari...
3
by: rcoco | last post by:
Hi, I want to share this problem. I have a datagrid that will help me Insert data into sql database. So I made a button On my form so that when I press the button a new row on datagrid should be...
4
Claus Mygind
by: Claus Mygind | last post by:
I want one or the other of two radio buttons to be checked depending on a substring of an incoming value. if the variable cOrder contains ID in the string then I want the first radio button...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.