我可以通过javascript向php链接添加一些内容吗?

我可以通过javascript向php链接添加一些内容吗?,javascript,Javascript,我有以下链接 http://localhost/benutzerdaten/singleentry.php?id=1 并希望向链接添加另一个参数。 这可能吗?我已经用.setatribute尝试过了,但这只允许我完全更改链接 感谢您的回复 带有我要添加内容的链接的表: echo "<table align='center' id='ftable' class='ftable'><tr><th>ID</th><th>Nam

我有以下链接
http://localhost/benutzerdaten/singleentry.php?id=1
并希望向链接添加另一个参数。 这可能吗?我已经用
.setatribute
尝试过了,但这只允许我完全更改链接

感谢您的回复

带有我要添加内容的链接的表:

        echo "<table align='center' id='ftable' class='ftable'><tr><th>ID</th><th>Name</th><<th>E-Mail</th><th>Telefon</th><th>Geburtsdatum</th><th>Straße</th><th>Details</th></tr>";
        // output data of each row
        while ($row = $result->fetch_assoc()) {

            echo "<td></td><tr><td>" . $row["id"] . "</td><td>" . $row["firstname"] ."&nbsp;". $row["lastname"] . "</td><td>" . $row["email"] . "</td>
                <td>" . $row["phone"] . "</td><td>" . $row["birthdate"] . "</td><td>" . $row["street"] . "</td>
                <td><a href='singleentry.php?id=" .$row["id"]."' class='details' id='details'>Details</a></td></tr>";
        }
        echo "</table>";
    } else {
        echo "0 results";
    }
echo“IDName您可以使用来轻松修改url的任何部分

const link=document.querySelector('a');
//从元素href创建url对象
const url=新url(link.href);
//设置搜索参数值
url.searchParams.set('bar',1);
//重新分配元素href属性
link.href=url;
//显示修订的href
console.log(link.href)

您是指在HTML中?还是指在浏览器的URL中?共享您的标记,共享您的代码没有足够的信息。“我已尝试使用.setaAttribute,但这只允许我完全更改链接”-您知道字符串连接是存在的,不是吗…?所以将新属性值设置为旧属性值+xyz,然后“问题”解决。(当然,还有更复杂的方法可以做到这一点,比如利用每个link元素还公开从
位置
对象中已知的属性这一事实,这样您就可以访问查询字符串部分,只从一开始就可以访问,并附加到该部分。)

function filterRows() {
    var input, filter, table, tr, td, cell, i, j, h, detailLink;
    input = document.getElementById("filterfeld");
    filter = input.value.toUpperCase();
    table = document.getElementById("ftable");
    tr = table.getElementsByTagName("tr");

        for (i = 1; i < tr.length; i++) {

            tr[i].style.display = "none";
            td = tr[i].getElementsByTagName("td");
            for (j = 0; j < td.length; j++) {
                cell = tr[i].getElementsByTagName("td")[j];

                if (cell) {

                    if (cell.innerHTML.toUpperCase().indexOf(filter) > -1) {
                        tr[i].style.display = "";

                        detailLink = cell.innerHTML;
                        if(detailLink.indexOf("href=") && document.getElementById("details").getAttribute('href') != "http://google.at"){
                            var el = document.querySelectorAll('.details');
                            for(h = 0; j < el.length; h++){
                            console.log(el[h].getAttribute('href'));
                            el[h].setAttribute('href',"");
                            console.log(el[h].getAttribute('href'));
                            }
                        }
                        break;
                    }
                }
            }
        }

}