Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IG Javascript Syntax

SJenkinsApr 25 2023

Apex 20.1 - Interactive Grid - using legacy theme, not Universal.

I need some help with a javascript

I want to set the background color of a cell when another cell is greater..

both cells have month abreviated and I convert to number..

javascript pulls values from both cells.. but the problem is, it loops through the second cell for every value of the first cell..

if I try to end the first loop then start the second loop I only get the last value of the first loop..


function highlight_ig_cells() {		

var months = {
   JAN : 01,
   FEB : 02,
   MAR : 03,
   APR : 04,
   MAY : 05,
   JUN : 06,
   JUL : 07,
   AUG : 08,
   SEP : 09,
   OCT : 10,
   NOV : 11,
   DEC : 12
   };


 //get value from col2 and convert to number
 $('.highlight td.c_award_let_month').each(function() {
       awardLM = $(this).text();
       if (!awardLM) 
           awardLM = '00';
        else
           awardLM = months[awardLM];
        //console.log(awardLM);

 // for each cell in col1 get value and convert to number		
 $('.highlight td.c_wkpln_let_month').each(function() {		
    // get cell text	
    wkplnLM = $(this).text();		
        if (!wkplnLM) 
          wkplnLM = '00';
        else
          wkplnLM = months[wkplnLM];
     //console.log(wkplnLM);

console.log(awardLM+' '+wkplnLM);    

// compare both
    if(awardLM>wkplnLM) 
	       this.style.backgroundColor = 'red';

     else
               this.style.backgroundColor = 'white'; 
   
}) //if i move this before the next cell I only get the last value of the first cell.. but here it loops the second cell values for every value of the first cell
}) 		
};

col1_val1 = col2_val1

col1_val1=col2_val1 (I want col2_val2)

This post has been answered by SJenkins on Apr 27 2023
Jump to Answer
Comments
Post Details
Added on Apr 25 2023
1 comment
209 views