根据php if condition [closed]删除表id

zengzsys  于 2023-03-28  发布在  PHP
关注(0)|答案(1)|浏览(127)

已关闭。此问题需要details or clarity。当前不接受答案。
**想要改进此问题?**添加详细信息并通过editing this post阐明问题。

5天前关闭。
社区在4天前审查了是否重新讨论此问题,并将其关闭:
原始关闭原因未解决
Improve this question
我有一个ID为example的表

<table id="example">
  <tr>
    <td>Emil</td>
    <td>Tobias</td>
    <td>Linus</td>
  </tr>
  <tr>
    <td>16</td>
    <td>14</td>
    <td>10</td>
  </tr>
</table>

我想删除ID,如果没有发布。

if (isset($_POST['save']))
 {
        ...
    
 }
 else
 {
        echo "
        <script>
        const box = document.getElementById('example');

        console.log(box.getAttribute('id'));

        box.removeAttribute('id'); 
        </script>";
 }

好像不能用,怎么办?

cbjzeqam

cbjzeqam1#

<?php
    if(isset($_POST['save'])) {
        $id="example";  
    }else{
        $id="";
    }
<table id="<?php echo $id; ?>">
  <tr>
    ..
  </tr>
  <tr>
   ..
  </tr>
</table>

请检查它是否适合您。

相关问题