On my HTML page, I have a table with a form in each row. Clicking on the row should open a detail page, but clicking within the form should not trigger this action.
Here is an example of what my row looks like:
<tr onclick="window.parent.location.href='details.php?id=123';"><td><img /></td><td>text</td><td>price<br>
<form method="post">
<input type="number" name="size" value="1">
<input type="submit" onsubmit="return confirm('Are you sure?');">
</form>
</td></tr>
The desired behavior is that if I click in the size field or on the submit button, the detail page should not be called.
I have researched and found that event.stopPropagation() can be used for this purpose, but I am struggling to implement it using plain JavaScript. It seems like there should be a straightforward solution, but I haven't been able to figure it out yet.