gpt4 book ai didi

javascript - PHP打印脚本无法识别javascript函数:

转载 作者:行者123 更新时间:2023-11-29 15:37:59 27 4
gpt4 key购买 nike

我正在尝试实现一个 javascript 函数来更改 tr 的样式。但是,它在我的 php 文件中未被识别,并且在我的 javascript 文件中未被使用。需要注意的是,td 中包含的按钮处于一个循环中,该循环会循环计算表的数量,然后将该数字添加到其 id 中。我省略了这段代码,因为它工作正常并且相当长。我从 phpstorm 收到的错误是:“表达式语句未分配或调用。”

PHP:

    <?php 
print "<script type='text/javascript' src='mainJS.js'></script>";
$amend_table = mysqli_query($con, "SELECT * FROM `$table`");
print "<table>";
if ($table === 'TBL_Product') {
print "<h2>Product Table Selected:</h2>";
print "<tr>";
for ($count = 0; $count < count($TBL_Product); $count++) {
print "<th>".$TBL_Product[$count]."</th>";
}
print "</tr>";
foreach ($amend_table as $item) {
print "<tr id='table$tr_count'>";
$tr_count++;
for ($count = 0; $count < count($TBL_Product); $count++) {
$current_item = $item[$TBL_Product[$count]];
$current_ID = $item['ProductID'];
if (strlen($current_item) <= 60) {
print "<td>".$current_item."</td>";
if ($TBL_Product[$count] === 'Finish') {
print "<td><button name='button$tr_count' onclick='edit_table($tr_count);'></button></td>";
}
}
else {
print "<th><span style='cursor: pointer' title='$current_item'>...</span></th>";
}
}
print "</tr>";
}
}
print "</table>";
?>

Javascript - (mainJS.js):

    function edit_table(tr_count) {
let table = 'table'+tr_count;
document.getElementById(table).style.border = 'orange 2px dashed';
}

最佳答案

抱歉,我的编辑应用程序 phpstorm 抛出了一个错误;该代码有效。感谢您的帮助!

关于javascript - PHP打印脚本无法识别javascript函数:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58026481/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com