Compare Values to Color Code Cells

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
jonathan.ayres
Posts:11
Joined: 2024-02-17 00:40

Compare Values to Color Code Cells

Post by jonathan.ayres » 2025-11-01 22:15

Good evening all!

I'm using the following snippit of code in 'footer-extras.php' and it's been working well...

Code: Select all

<script>
$j(function(){
$j('td.service-pctused').each(function(){
var eff = $j(this).text();
if ((eff < 90.00) && (eff > 75.00)){
$j(this).addClass('warning');
}
})
})
</script>
I would like to do something similar in another table to compare on hand inventory to minimum stocking levels, and then color code them as appropriate.

My fields are
Current Stock - prod.currentstock
Minimum Stock - prod.minstock

I know I need to pull the fields are variables and compare; but that's where I'm running into the issue of how to pull both variables and the "if" statement that makes it happen correctly.

Any advise?

Thanks!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts:1757
Joined: 2018-04-01 10:12

Re: Compare Values to Color Code Cells

Post by pbottcher » 2025-11-05 19:30

Hi,

you may try something like to get to the values as a starting point.

Code: Select all

<script>
$j(function(){
  $j('td.prod.currentstock').each(function(){
     var currentstock= $j(this).text();
     var ministock =$j(this).parents('tr').find('td.prod.minstock').text()
     if (currentstock WHATEVER ministock)){
       $j(this).addClass('warning');
    }
  })
})
</script>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jonathan.ayres
Posts:11
Joined: 2024-02-17 00:40

Re: Compare Values to Color Code Cells

Post by jonathan.ayres » 2025-11-09 18:23

pbottcher, thanks! Tried that with changing the whatever to <= and some other variables; but still not working...

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts:1757
Joined: 2018-04-01 10:12

Re: Compare Values to Color Code Cells

Post by pbottcher » 2025-11-09 18:41

Hi,

check for the class of the respective row. I would guess it is not

prod.currentstock, but something like prod-currentstock
prod.minstock -> prod-minstock

but you need to look at that as I cannot see what your classes are.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jonathan.ayres
Posts:11
Joined: 2024-02-17 00:40

Re: Compare Values to Color Code Cells

Post by jonathan.ayres » 2025-12-01 00:10

Yeah, tried that too... still coming up nothing... Any other thoughts?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts:1757
Joined: 2018-04-01 10:12

Re: Compare Values to Color Code Cells

Post by pbottcher » 2025-12-01 20:10

Hi, can you post a screenshot of the DOM displaying your field and the code you tried?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jonathan.ayres
Posts:11
Joined: 2024-02-17 00:40

Re: Compare Values to Color Code Cells

Post by jonathan.ayres » 2026-02-19 21:57

This is the current script and the structure:

Table Name: prod
Fields: currentstock, minstock

Code: Select all

<script>
$j(function(){
  $j('prod-currentstock').each(function(){
     var currentstock = $j(this).text();
     var minstock = $j(this).parents('tr').find('prod-minstock').text()
     if (currentstock < minstock)){
       $j(this).addClass('warning')
    }
  })
})
</script>

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts:1757
Joined: 2018-04-01 10:12

Re: Compare Values to Color Code Cells

Post by pbottcher » 2026-02-19 22:33

Hi,

try

Code: Select all

<script>
$j(function(){
  $j('prod-currentstock').each(function(){
     var currentstock = $j(this).text();
     var minstock = $j(this).parents('tr').find('td.prod-minstock').text()
     if (currentstock < minstock)){
       $j(this).addClass('warning')
    }
  })
})
</script>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply