So I have this text called 'Documentation', with a normal href when i left-click. But when i right click it opens a popup window, as it should. It works great when i only have one id, but lets say i choose 10 [0 1 2 3 4 5 6 7 8 9], then 9 will be the only one linked to once: EditText?testjobid=9. The link also get attached to the 'Documentation' with id = 0. What am i doing wrong?
foreach ($AllTestResultsTestJob as $TestJob)
{
$testjobid = $TestJob['TestjobId'];
echo "<th style=''><center><a id='EditText' style='color:#000' class='links' href= 'Documentation?testjobid=".$testjobid."' target='_blank'>Documentation</th>";
</center>
</th>";
echo"
<script>
document.getElementById('EditText').onmousedown = function(event) {
if (event.which == 3) {
window.open('EditText?testjobid=".$testjobid."', 'myWindow', 'width=1000,height=390');
}
}
</script>
";
Your are using the same id='EditText' for multiple element, so you should change your id and select those link with another selector.
So change your link to:
echo "<th style=''><center><a id='EditText-".$testjobid."' style='color:#000' class='links' href= 'Documentation?testjobid=".$testjobid."' target='_blank'>Documentation</th>";
And change your event to:
echo"
<script>
document.getElementById('EditText-".$testjobid."').onmousedown = function(event) {
if (event.which == 3) {
window.open('EditText?testjobid=".$testjobid."', 'myWindow', 'width=1000,height=390');
}
}
</script>
";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.