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

178
Views
Loop is not working in this switch case jquery

Loop is not initiating in this code and also split_value doesn't store any value. I want to compare dropdown value and excel data and then matched value should store in sum = [].

if (items) {
  switch (currentControl) {
    case "Record_Code":
      var dropdownvalue1 = $.map($('#ddlOrderSourceEligibilityGoaloption'), function(ele) {
        return {
          text: ele.text,
          value: ele.value
        }

        for (var v = 0; v < myitem.length; v++) {
          isFound = 0;

          for (i = 0; i < dropdownvalue1.length; i++) {
            var split_value = dropdownvalue1[i].text.split('-');

            if ((myitem[v].split('-')[0]).trim() == (split_value[0]).trim()) {
              sum.push(dropdownvalue1[i].value);
              isFound = 1;
              break;
            }
          }

          if (isFound == 0) {
            NotFound.push(myitem[v]);
          }
        }

        if (sum.length > 0) {
          setMultiSelectValue("#ddlOrderSourceEligibilityGoal", sum);
          $(".uploadExcelTE").val('');
        }
      });
      break;

    case "Order_Source":
      break;

    case "Order_Type":
      break;

    case "Bill_To_Cust":
      break;

    case "Item_Status":
      break;
  }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The problem is that you use a return statement in the first block of the switch-case statement. If currentControl is "Record_Code", the program always assigns dropdownvalue1 the value {text: ele.text, value: ele.value}.

if (items) 
{
  switch (currentControl) 
  {
    case "Record_Code":
      var dropdownvalue1 = $.map($('#element'), function (ele) {
        // The dropdownvalue1 variable is always assigned the following result.
        return { text: ele.text, value: ele.value }
                
        // The code blocks below never work.
        for(var v = 0; v < myitem.length ; v++){}
      });
      break;
  }
}
over 4 years ago · Santiago Trujillo 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!