0

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.. enter image description here

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" />
2
  • 2
    <align="center" isn't a valid element Commented Oct 18, 2016 at 15:30
  • Also you don't close your tags, which might be why your first click handler lies over both images and your second client handle only over the second. Commented Oct 18, 2016 at 15:33

2 Answers 2

1

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" />
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect, makes sense.. Thank you!
0

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.

1 Comment

Thank you, basically the same thing as above.. very helpful thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.