469,328 Members | 1,327 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

retrieve the element wich have the focus

Cui
Hi, and sorry for my poor english

I have dynamically created some checkbox in a table, and I have also
attached to it some event.

mycurrent_cell = document.createElement("TD") ;
chbox = document.createElement("INPUT") ;
chbox.type = "CHECKBOX" ;
chbox.name = "CHB_" & col_i ; // col_i is an integer....
chbox.attachEvent("onclick", chbox_click) ;
chbox.attachEvent("ondblclick", chbox_dblclick) ;
In the chbox_click and chbox_dbclick functions, I want retrieve the element
which has generated the action. I tried to get it by the name:
element = event.srcElement ;
element.name => always returned the value : 1

Then , I want to know how I can do it.When ones uses attachEvent method, the
2nd parameter is the name of the function, but it is impossible to pass some
parameters.

Do I must change the attachEvent call, or use anything else of event and
event.srcElement..

Thanks

Cui
Jul 23 '05 #1
3 1539
Cui wrote:
<snip>
chbox.name = "CHB_" & col_i ; // col_i is an integer....

<snip>
^
& is the bitwise AND operator in javascript (that operation will always
have a numeric result corresponding with - col_i - (assuming col_i can
be represented as a 32 bit signed integer)). You want the string
concatenation operator:-

chbox.name = "CHB_" + col_i;

Richard.
Jul 23 '05 #2
Cui
OK, I find my error.

the lines :
element = event.srcElement;
element.name
are OK.

I confuse the concatenation operator in javascript ('+') and in vb.net (
'&').

Thanks for your help.
"Cui" <cu**************************@free.fr> a écrit dans le message de
news: 40*********************@nnrp1.numericable.fr...
Hi, and sorry for my poor english

I have dynamically created some checkbox in a table, and I have also
attached to it some event.

mycurrent_cell = document.createElement("TD") ;
chbox = document.createElement("INPUT") ;
chbox.type = "CHECKBOX" ;
chbox.name = "CHB_" & col_i ; // col_i is an integer....
chbox.attachEvent("onclick", chbox_click) ;
chbox.attachEvent("ondblclick", chbox_dblclick) ;
In the chbox_click and chbox_dbclick functions, I want retrieve the element which has generated the action. I tried to get it by the name:
element = event.srcElement ;
element.name => always returned the value : 1

Then , I want to know how I can do it.When ones uses attachEvent method, the 2nd parameter is the name of the function, but it is impossible to pass some parameters.

Do I must change the attachEvent call, or use anything else of event and
event.srcElement..

Thanks

Cui

Jul 23 '05 #3
Cui
ok. I make a mistale. Thanks for your precision. Now, it is correct.

"Richard Cornford" <Ri*****@litotes.demon.co.uk> a écrit dans le message de
news: c4*******************@news.demon.co.uk...
Cui wrote:
<snip>
chbox.name = "CHB_" & col_i ; // col_i is an integer....

<snip>
^
& is the bitwise AND operator in javascript (that operation will always
have a numeric result corresponding with - col_i - (assuming col_i can
be represented as a 32 bit signed integer)). You want the string
concatenation operator:-

chbox.name = "CHB_" + col_i;

Richard.

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Paul Thompson | last post: by
22 posts views Thread by DJ WIce | last post: by
9 posts views Thread by s_m_b | last post: by
3 posts views Thread by Praveen | last post: by
3 posts views Thread by Burak Kadirbeyoglu | last post: by
15 posts views Thread by Christoph | last post: by
2 posts views Thread by yawnmoth | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.