Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
In Javascript function onLoadPopulate() is not working?
function onLoadPopulate() {
    var grid = $("#grid0");
    var numberOfRecords = grid.getGridParam("records");
    var dataFromGrid = grid.jqGrid('getGridParam', 'data');
    var count=0;
    var link;
    if(numberOfRecords>0){
    numberOfRecords=endNo;
    count=begNo-1;  
    }
    for ( ; count < numberOfRecords; count++) {

        var program = dataFromGrid[count].program;
        var programVal="";
        
     var programs = program.replace(/\s/g,'').split(',');
        
     for ( var i = 0; i< programs.length;i++) {
            
            if (programs[i] == "FS") {
                if (programVal == "") {
                    programVal = 'DOG';
                } else {
                    programVal = programVal.concat(",DOG");
                }
            } else if (programs[i]  == "TF") {
                console.log("in TF");
                if (programVal == "") {
                    programVal = 'CAT';
                } else {
                    programVal = programVal.concat(",CAT");
                }
        
        }
        grid.jqGrid('setCell', count + 1, 'program',
                programVal);
        }
}

TEST DATA:

program = FS, TF

result i'm getting : DOG but the result i need : DOG,CAT

When it is doing else if Even if programs[i] = TF it is skipping if loop inside.

Can anyone help with this JavaScript function? I can't figure it out what is wrong.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

issue with input data consisted of special characters i used following replace and it worked

.replace(/[^a-z0-9,\s]/gi,'').replace(/[_\s]/g,'').split(',')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!