Kyle Vbcrlf Rickaby
Kyle Vbcrlf Rickaby

Reputation: 87

HTML / Javascript .. Button click calls two scripts?

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" />

Upvotes: 0

Views: 60

Answers (2)

David W
David W

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

tcooc
tcooc

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

Related Questions