Reputation: 87
I have a page, that shows two buttons... I only want 1 of the javascript functions called depending on the image they click...
Here is a picture of what I am talking about..
So, when I click on the first box... I get the correct javascript function called.
When I click the second box, it calls both of the functions.
Here is my code:
<td align="center" valign="center" onClick="submitRow1('<% =rsTemp1("Created") %>','<% =rsTemp1("CSN") %>','<% =rsTemp1("PartNum") %>','<% =rsTemp1("TicketNum") %>', '<% =rsTemp1("Liability") %>')" nowrap class="bodyTextTLR"><img src="images/Invoiced.png" />
<align="center" valign="center" onClick="submitRow3('<% =rsTemp1("Created") %>','<% =rsTemp1("CSN") %>','<% =rsTemp1("PartNum") %>','<% =rsTemp1("TicketNum") %>', '<% =rsTemp1("Liability") %>')" nowrap class="bodyTextTLR"><img src="images/NoInvoice.png" />
Upvotes: 0
Views: 60
Reputation: 10184
Your <TD>
tag is not properly closed with a </TD>
tag. As a result, the click handler you've specified at the cell level is engaged for the contained elements. You should consider attaching the handlers to the <img>
elements individually.
Upvotes: 0
Reputation: 21229
Since your image shows 2 images in one table cell, the way to do it is to have a <td>
element containing the 2 images, and bind the click handlers to those images directly:
<td align="center" valign="center" nowrap class="bodyTextTLR">
<img onClick="submitRow1('<% =rsTemp1("Created") %>','<% =rsTemp1("CSN") %>','<% =rsTemp1("PartNum") %>','<% =rsTemp1("TicketNum") %>', '<% =rsTemp1("Liability") %>')" src="images/Invoiced.png" />
<img onClick="submitRow3('<% =rsTemp1("Created") %>','<% =rsTemp1("CSN") %>','<% =rsTemp1("PartNum") %>','<% =rsTemp1("TicketNum") %>', '<% =rsTemp1("Liability") %>')" src="images/NoInvoice.png" />
Upvotes: 1