test array search filter

by aidankirrane

HTML

<input id="txtOSA">

<input id="txtRadio">

<select  id="Startdate">
  <option value="11-Sep-2018 07:15">11-Sep-2018 07:15</option>
  <option value="11-Sep-2018 07:30">11-Sep-2018 07:30</option>
  <option value="11-Sep-2018 07:45">11-Sep-2018 07:45</option>
  <option value="11-Sep-2018 08:00">11-Sep-2018 08:00</option>
  <option value="11-Sep-2018 08:15">11-Sep-2018 08:15</option>
  <option value="11-Sep-2018 16:30">11-Sep-2018 16:30</option>
  <option value="11-Sep-2018 15:45">11-Sep-2018 15:45</option>
  <option value="11-Sep-2018 16:00" selected>11-Sep-2018 16:00</option>
  <option value="11-Sep-2018 16:15">11-Sep-2018 16:15</option>
</select>

JavaScript

var respObj = ({
  "Data": {
    "EmployeeList": [{
        "CallingEmployee": "TRUE",
        "DigitalRadioId": "4132351253",
        "EmployeeId": 10018,
        "OsaDeviceId": "123"
      },
      {
        "CallingEmployee": "FALSE",
        "DigitalRadioId": "90210",
        "EmployeeId": 101904808,
        "OsaDeviceId": null
      }
    ],
    "EquipmentList": [
      "BUSHMASTER",
      "TDD"
    ],
    "ShiftDuration": 28800,
    "ShiftEnd": "11-Sep-2018 16:00",
    "ShiftStart": "11-Sep-2018 08:05",
    "SpecialContact": "123456",
    "VehicleId": "PL6317"
  },
  "Message": "Process completed successfully",
  "ResultCode": 0
});
// (Note that because `price` and such are given as strings in your object,
// the below relies on the fact that <= and >= with a string and number
// will coerce the string to a number before comparing.)
var array_EmployyeeListWithOnlyTheCallingEmployee = respObj.Data.EmployeeList.filter(function (el) {
  return el.CallingEmployee == "TRUE"; // Changed this so a home would match
});

    var elm_txtOSA = document.getElementById('txtOSA');
    var elm_txtRadio = document.getElementById('txtRadio');
    
elm_txtOSA.value = array_EmployyeeListWithOnlyTheCallingEmployee[0].OsaDeviceId;
elm_txtRadio.value = array_EmployyeeListWithOnlyTheCallingEmployee[0].DigitalRadioId;



  var equipments = respObj.Data.EquipmentList;
  //get DocumentS plural for collection
  //var checkboxes = document.getElementsByName("unitequipment");
 // alert(equipments.length);
  
  
    var elm_ShiftStart = document.getElementById('Startdate');
    var optiontocheck=respObj.Data.ShiftStart;
    var bfoundAllready=false;
    for (var k = 0; k < elm_ShiftStart.length; k++) {
        if(elm_ShiftStart.options[k].value>=optiontocheck && bfoundAllready == false)
        {
            elm_ShiftStart.selectedIndex = k;
            bfoundAllready=true;
        }
      }
      
      
   // var element = document.getElementById('Startdate');
  //  element.value =...