[英]How to make a clickable cell in JavaScript?
I am using Data Table from CSS- bootstrap 4 data.tables https://datatables.net/examples/styling/bootstrap4我正在使用 CSS-bootstrap 4 data.tables 中的数据表https://datatables.net/examples/styling/bootstrap4
Please look at the image请看图片
The Row is clickable and it redirects me to another page1.该行是可点击的,它将我重定向到另一个页面 1。 BUT when I click on Find Location button, it does redirect me on page1 and page2 as well.
但是,当我单击“查找位置”按钮时,它也会在 page1 和 page2 上重定向我。 I just want to go to page2.
我只想go到page2。 The code is below
代码如下
index.php index.php
<tr onclick="xdata(this)">
<td ><?php echo $event->description ? $event->description->type : null; ?></td>
<td><?php echo $event->description ? $event->description->text : null; ?></td>
<td><?php echo $event->origin && $event->origin->time? $event->origin->time->value: null; ?></td>
<form method="get" action="findLocation.php">
<input type="hidden" name="LongitudeValue" value="<?php echo $event->origin && $event->origin->longitude? $event->origin->longitude->value : null; ?>" />
<td><input type="submit" value="FIND LOCATION" style="margin: auto; width: 100%; border: 3px solid green; padding: 1px;" /></td>
</form>
</td>
app.js应用程序.js
function xdata(e){
// Shows how to get data from each column of this row
c2 = e.children.item(1).innerHTML;
// open new page
window.open('indexXML_SEARCH.php?SearchValue='+c2, '_blank');
}
HOW can I click my findLocation button without it redirecting me to page1 but to page2 because whenever I press the button it opens a new window for page1 and the current page is redirected to page2.我如何才能单击我的 findLocation 按钮而不会将我重定向到 page1 但到 page2 因为每当我按下按钮时它都会为 page1 打开一个新的 window 并且当前页面被重定向到 page2。 I just want page2 when button is clicked.
单击按钮时我只想要 page2。
Note that when I click on the row (not the button) everything works fine whereby the page1 must be loaded that is open in a new window!请注意,当我单击该行(而不是按钮)时,一切正常,因此必须加载在新窗口中打开的 page1!
I am reading from XML and displaying thus, this is the code:
I cannot merge both code in One line for example:
if this php echo $event->origin && $event->origin->quality? HAS
SOMETHING!!, it returns $event->origin->quality->usedPhaseCount ELSE
null
<td><?php echo $event->origin && $event->origin->quality? $event-
>origin->quality->usedPhaseCount: null; ?></td>
I want it The input button below to be in the second condition :
<td><input onclick="func1(event)" type="submit" value="FIND LOCATION"
style="margin: auto; width: 100%; border: 3px solid green; padding:
1px;" /></td>
What I want But Parse error: syntax error, unexpected token "<"
<td><?php echo $event->origin && $event->origin->quality?
<input onclick="func1(event)" type="submit" value="FIND LOCATION"
style="margin: auto; width: 100%; border: 3px solid green; padding:
1px;" />: null; ?></td>
The code is not clear and complete.代码不清晰,不完整。 However, I presume that you have defined onclick events for both
<tr>
and <td>
tags and when you click the <td>
, it also triggers the <tr>
event.但是,我假设您已经为
<tr>
和<td>
标签定义了 onclick 事件,当您单击<td>
时,它也会触发<tr>
事件。 To prevent this, add this code at the end of your <td>
event handler.为防止这种情况,请在
<td>
事件处理程序的末尾添加此代码。
event.stopPropagation();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.