how to use following code recursively for different tables

Prabhu Chaitanya varma
Query(document).ready(function() {
  var trCount = $('.Firsttable tr').length;

  for (var i = 4; i <=4; i++) {

    var $td = $('.Firsttable tr:eq(2) td:eq(' + i + ')'),
      highest = 0,
      lowest = 9e99;

    for (var j = 1; j < trCount; j++) {
      $td = $td.add('.Firsttable tr:eq(' + j + ') td:eq(' + i + ')');
    }

    $td.each(function(i, el){
      var $el = $(el);
      if (i > 0) {
        var val = parseInt($el.text().replace(/[\$,]/g, ''), 10);
        if (val < lowest) {
            lowest = val;
            $td.removeClass('low');
            $el.addClass('low');
        }
      }
    });
  }
BabyDuck

Assign ID attribute to each of your tables and write a function like this:

<script type="text/javascript">
function testTable(tableId) {
  var trCount = $('#'+ tableId +' tr').length;

  for (var i = 4; i <=4; i++) {

    var $td = $('#'+ tableId +' tr:eq(2) td:eq(' + i + ')'),
      highest = 0,
      lowest = 9e99;

    for (var j = 1; j < trCount; j++) {
      $td = $td.add('#'+ tableId +' tr:eq(' + j + ') td:eq(' + i + ')');
    }

    $td.each(function(i, el){
      var $el = $(el);
      if (i > 0) {
        var val = parseInt($el.text().replace(/[\$,]/g, ''), 10);
        if (val < lowest) {
            lowest = val;
            $td.removeClass('low');
            $el.addClass('low');
        }
      }
    });
}
</script>

Now just call this function for every table by passing it's id,

<script type="text/javascript>
Query(document).ready(function() {
   testTable('table1');
   testTable('table2');
}
</script>

Hope it helps, thanks.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use the following Semaphore code

From Dev

How to use SHOW TABLES with different tables in sql?

From Dev

How to refactor the following code to use q?

From Dev

Why are there different results for the following code?

From Dev

How to use a function recursively?

From Dev

how can i use function in $message statement in the following code

From Dev

How to use python's list comprehensions to execute the following matlab code?

From Dev

How to use the following code if larger sets of data are provided using matlab?

From Dev

How to use 1 id for everything instead of 3 (for the following code)

From Dev

how to optimize the following code?

From Dev

How to read the following code?

From Dev

how to decode following code

From Dev

How do I use the following R code to reproduce the following plot with the ggplot2 package?

From Dev

Regarding use of assempde in the following code

From Dev

How to use xsl:if for the following?

From Dev

JXB How to use different strategies of code generation

From Dev

JXB How to use different strategies of code generation

From Dev

How to use different tablespaces for tables and indexes with liquibase in Java

From Dev

how to use triggers when comparing two data from different tables?

From Dev

How to create two Tables in JavaScript and use with different CSS?

From Dev

Can the following code be true for pointers to different things

From Dev

how to join different tables?

From Dev

Use a signal to update different tables

From Dev

How to write sql query for the following tables

From Dev

How to join two tables to get the following result?

From Dev

Collect data from 2 different tables, following conditions

From Dev

How to recursively delete multiple files with different extensions?

From Dev

How to identify the following code patterns

From Dev

How to vectorize the following python code?

Related Related

  1. 1

    How to use the following Semaphore code

  2. 2

    How to use SHOW TABLES with different tables in sql?

  3. 3

    How to refactor the following code to use q?

  4. 4

    Why are there different results for the following code?

  5. 5

    How to use a function recursively?

  6. 6

    how can i use function in $message statement in the following code

  7. 7

    How to use python's list comprehensions to execute the following matlab code?

  8. 8

    How to use the following code if larger sets of data are provided using matlab?

  9. 9

    How to use 1 id for everything instead of 3 (for the following code)

  10. 10

    how to optimize the following code?

  11. 11

    How to read the following code?

  12. 12

    how to decode following code

  13. 13

    How do I use the following R code to reproduce the following plot with the ggplot2 package?

  14. 14

    Regarding use of assempde in the following code

  15. 15

    How to use xsl:if for the following?

  16. 16

    JXB How to use different strategies of code generation

  17. 17

    JXB How to use different strategies of code generation

  18. 18

    How to use different tablespaces for tables and indexes with liquibase in Java

  19. 19

    how to use triggers when comparing two data from different tables?

  20. 20

    How to create two Tables in JavaScript and use with different CSS?

  21. 21

    Can the following code be true for pointers to different things

  22. 22

    how to join different tables?

  23. 23

    Use a signal to update different tables

  24. 24

    How to write sql query for the following tables

  25. 25

    How to join two tables to get the following result?

  26. 26

    Collect data from 2 different tables, following conditions

  27. 27

    How to recursively delete multiple files with different extensions?

  28. 28

    How to identify the following code patterns

  29. 29

    How to vectorize the following python code?

HotTag

Archive