简体   繁体   English

如何使用javascript或php根据其他单元格的值添加特定于值的列?

[英]How to add a column specific with values depending on other cell's value using javascript or php?

Let's say for example column dropdown represents a type of membership and depending on the value of dropdown, I would like to be able to display a column next to it that indicates the maximum number of companions I could bring.假设例如列下拉列表代表一种成员资格,并且根据下拉列表的值,我希望能够在它旁边显示一列,指示我可以携带的最大同伴数量。 Is there a way to do it via javascript or PHP or maybe SQL itself?有没有办法通过javascript或PHP或SQL本身来做到这一点?

<?php
        foreach ($dbh->query($sql) as $rows){
        ?>
        <tr>
            <td><?php echo $rows['name']?></td>
            <td><?php echo $rows['email']?></td>
            <td><?php echo $rows['number']?></td>
            <td><?php echo $rows['org']?></td>     
            <td><?php echo $rows['dropdown']?></td>
            <td><?php echo $rows['date']?></td>
        </tr>
     <?php
      }
     ?>

Code:代码:

<?php
    foreach ($dbh->query($sql) as $rows){
    ?>
    <tr>
        <td id="<?=$rows['id']?>"><?php echo $rows['name']?></td>
    </tr>
 <?php
  }
 ?>

By clicking on the ajax button you will take the ID attribute of the column, send a request with the received id and add the value to the column created next to it.通过单击 ajax 按钮,您将获取列的 ID 属性,使用接收到的 ID 发送请求并将值添加到旁边创建的列中。

If I understand you correctly.如果我理解正确的话。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何根据AJAX / PHP / JAVASCRIPT的另一列实时显示数据值? - How to display data value in real time depending on the other column with AJAX/PHP/JAVASCRIPT? 如何根据其他值在选择项上显示特定值? - How to show specific values on a select depending of other value? 根据使用javascript的值为表格的单元格着色 - Color the cell of a table depending on the value using javascript 如何通过javascript将值从一页传递到另一页,并使用php获取另一页中传递的值? - How to pass values from one page to other page by javascript and get the passed value in the other page using php? 如何仅使用Onkeyup Javascript获取特定的列单元格值并求和该值 - How to get particular column cell values and sum that value using Onkeyup only Javascript 如何使用 javascript 根据 html 中的条件循环具有不同键值对的 JSON 数组以显示特定值 - how to loop over JSON array having different key value pairs to display specific values depending on condition in html using javascript 如何使用javascript循环键,值并在另一个匹配时添加一个键的值 - How to use javascript to loop through key , values and add up one key's value when the other's match 如何根据 JavaScript 中的其他列值更改表格的列单元格颜色? - How to change column cell color of a table based on other column value in JavaScript? 使用Javascript根据其他键的存在显示JSON值 - Display JSON values depending on presence of other key using Javascript 如何使用javascript将内容添加到csv中的特定列? - How to add content to specific column in csv using javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM