jeudi 27 septembre 2018

logic in if/else method in javascript

i just want to implement if else method in my apps the problem is when in choose the first if it working, but if i choose second if its not working, this is my code

  //filter in session
   filterMarkersx = function (session) {

      var table = $('#edcTable').DataTable().column(1).column(2); 


     var str;


        $("select#type option:selected" ).each(function() {
            str = $(this).val();
        }); 


       for (i = 0; i < gmarkers1.length; i++) {
           marker = gmarkers1[i];
            if(marker.session == session || session.length === 0) {
                   marker.setVisible(true); 
           } else if(marker.session == session || session.length === 0) {
               if (marker.category == str || $("#type").length === 0){
                   marker.setVisible(true); 
               }
           }else{
               marker.setVisible(false);
               infowindow.close(map, marker1);
           }
       }


       table.search(str).draw();

   }  

anyone can help me what must i do, thanks in advance.

-kraken.

Aucun commentaire:

Enregistrer un commentaire