Refer to current DIV tag

M

mouac01

I need to tell which DIV tag the event occurred on. For example, I
have 3 DIV tags. Inside each DIV tag I have an INPUT text with the
same name. Say if I change the value of the INPUT text in the second
DIV tag (line_2), how can I identify that the change occurred in that
DIV. I was hoping to use something like 'this.div' but that doesn't
seem to work. I don't want to hardcode each DIV id on the onchange
event. Thanks...

function oC(div){
alert(div.id);
}

<DIV id="line_1">
<INPUT type="text" name="fld" onchange="oC(this.div)">
</DIV>
<DIV id="line_2">
<INPUT type="text" name="fld" onchange="oC(this.div)">
</DIV>
<DIV id="line_3">
<INPUT type="text" name="fld" onchange="oC(this.div)">
</DIV>
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top