Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript codeigniter中jquery中的绿色到红色渐变色_Javascript_Php_Jquery_Html_Codeigniter - Fatal编程技术网

Javascript codeigniter中jquery中的绿色到红色渐变色

Javascript codeigniter中jquery中的绿色到红色渐变色,javascript,php,jquery,html,codeigniter,Javascript,Php,Jquery,Html,Codeigniter,我计算数据并从数据库中提取数据,并以百分比格式显示在表中 这是我的桌子 <table id="myTable" class="myTable"> <thead> <tr class=""> <th>Types of Work</th> <th>value</th> <th>Count Percent(%)</th> <th>Hours<

我计算数据并从数据库中提取数据,并以百分比格式显示在表中

这是我的桌子

<table id="myTable" class="myTable">
<thead>
  <tr class="">
    <th>Types of Work</th>
    <th>value</th>
    <th>Count Percent(%)</th>
    <th>Hours</th>
    <th>Hours Percent(%)</th>
  </tr>
</thead>
<tbody>
<?php $count=0; 
      $count_percent=0;
      $total_time=0;
?>
  <?php foreach($result as $row) { ?>
      <tr>
      <td><?php echo $row->t_name;?></td>
      <td><?php echo $row->NUM;?></td>
      <td><?php echo round($row->count_percent,1)."%";?></td>
      <td><?php echo round($row->value_sum,1);?></td>
      <td><?php echo round($row->duration_percent,1)."%";?></td>
      </tr>
      <?php
        $count += $row->value_sum; 
        $total_time += $row->NUM;  
      } 
      ?>
      <tr>
        <td>Total</td>
        <td><?php echo "$total_time";?></td>
        <td></td>
        <td><?php echo round("$count",1); ?></td>
        <td></td>
      </tr>
</tbody>
</table>
我在谷歌上搜索,但没有找到答案


请帮我找到解决方案

有人在吗请帮我找到答案你可以制作一个带有多个颜色选项的关联数组,然后根据百分比选择一种颜色,这样就足够了吗?@Andrew。我在javascript方面没有太多的知识,请帮助我,我不清楚你在问什么。你想要一个进度条吗?在何处/为什么应用此渐变?请将您的问题修改为(当“x”时,我想是“y”。我已经尝试了“z”)@FissureKing我相信他正在尝试根据百分比获得红色和绿色之间的阴影
$(".myTable .valueTD").each(function(){
    var r = Math.min(100,parseInt(this.innerHTML,10)*2+10);
    var g = Math.min(100,200-parseInt(this.innerHTML,10)*2+10);
    this.style.backgroundColor = "rgb(" + g + "%," + r + "%,0%)"
});