retrieve the element wich have the focus

C

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
 
R

Richard Cornford

Cui wrote:
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.
 
C

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top