Skip to main content
Bounty Ended with 50 reputation awarded by Baby in Magento
added 52 characters in body
Source Link
Dhiren Vasoya
  • 9.5k
  • 12
  • 35
  • 59

You can do this things to,

  1. Before showing product value in dropdown, Call one Ajax Requestion

  2. In Ajax Request pass that Product Id

  3. Now on that ajax url, in php code check that product_id is show or not in dropdown

  4. Based on Ajax request result can add that value in dropdown or not.

    function getProductDetail(e)
      {    
        var productId = $("#dproductselect option:selected").attr("class");  
        var finalstrig=productId.split(",");
    
        var select='';
        select+='<select class="test" multiple="multiple" name="dproduct_ids" id="dproduct_ids">';
    
        for(i=0;i<finalstrig.length;i++)
        {
           //CREATE ONE AJAX CALL TO CHECK IS THIS PRODUCT ID SHOW IN DROPDOWN OR NOT 
           var returnresult = 0;
           var url="SOMEURLurl="http://sbdev2.kidsdial.com:81/php/site6/productdropdown.php?p_id="+finalstrig[i]; 
           var request = jQuery.ajax( {
                url: url ,
                type: 'POST',                      
            } );
    
            request.done( function (result)
            {  
               returnresult = 1;
    
            });
            request.fail( function ( error )
            {
                console.dir(error);             
            } );
    
          if(finalstrig[i]!=0 && returnresult)
          {
            select +='<option value="'+finalstrig[i]+'">'+finalstrig[i]+'</option>';
          }
        }
        select +='</select>';   
        document.getElementById('productnumbers').innerHTML =select;
        (function($) {
        $(function() {
            $('.test').fSelect();
        });
    })(jQuery);
    
      }
    

You can do this things to,

  1. Before showing product value in dropdown, Call one Ajax Requestion

  2. In Ajax Request pass that Product Id

  3. Now on that ajax url, in php code check that product_id is show or not in dropdown

  4. Based on Ajax request result can add that value in dropdown or not.

    function getProductDetail(e)
      {    
        var productId = $("#dproductselect option:selected").attr("class");  
        var finalstrig=productId.split(",");
    
        var select='';
        select+='<select class="test" multiple="multiple" name="dproduct_ids" id="dproduct_ids">';
    
        for(i=0;i<finalstrig.length;i++)
        {
           //CREATE ONE AJAX CALL TO CHECK IS THIS PRODUCT ID SHOW IN DROPDOWN OR NOT 
           var returnresult = 0;
           var url="SOMEURL?p_id="+finalstrig[i]; 
           var request = jQuery.ajax( {
                url: url ,
                type: 'POST',                      
            } );
    
            request.done( function (result)
            {  
               returnresult = 1;
    
            });
            request.fail( function ( error )
            {
                console.dir(error);             
            } );
    
          if(finalstrig[i]!=0 && returnresult)
          {
            select +='<option value="'+finalstrig[i]+'">'+finalstrig[i]+'</option>';
          }
        }
        select +='</select>';   
        document.getElementById('productnumbers').innerHTML =select;
        (function($) {
        $(function() {
            $('.test').fSelect();
        });
    })(jQuery);
    
      }
    

You can do this things to,

  1. Before showing product value in dropdown, Call one Ajax Requestion

  2. In Ajax Request pass that Product Id

  3. Now on that ajax url, in php code check that product_id is show or not in dropdown

  4. Based on Ajax request result can add that value in dropdown or not.

    function getProductDetail(e)
      {    
        var productId = $("#dproductselect option:selected").attr("class");  
        var finalstrig=productId.split(",");
    
        var select='';
        select+='<select class="test" multiple="multiple" name="dproduct_ids" id="dproduct_ids">';
    
        for(i=0;i<finalstrig.length;i++)
        {
           //CREATE ONE AJAX CALL TO CHECK IS THIS PRODUCT ID SHOW IN DROPDOWN OR NOT 
           var returnresult = 0;
           var url="http://sbdev2.kidsdial.com:81/php/site6/productdropdown.php?p_id="+finalstrig[i]; 
           var request = jQuery.ajax( {
                url: url ,
                type: 'POST',                      
            } );
    
            request.done( function (result)
            {  
               returnresult = 1;
    
            });
            request.fail( function ( error )
            {
                console.dir(error);             
            } );
    
          if(finalstrig[i]!=0 && returnresult)
          {
            select +='<option value="'+finalstrig[i]+'">'+finalstrig[i]+'</option>';
          }
        }
        select +='</select>';   
        document.getElementById('productnumbers').innerHTML =select;
        (function($) {
        $(function() {
            $('.test').fSelect();
        });
    })(jQuery);
    
      }
    
Source Link
Dhiren Vasoya
  • 9.5k
  • 12
  • 35
  • 59

You can do this things to,

  1. Before showing product value in dropdown, Call one Ajax Requestion

  2. In Ajax Request pass that Product Id

  3. Now on that ajax url, in php code check that product_id is show or not in dropdown

  4. Based on Ajax request result can add that value in dropdown or not.

    function getProductDetail(e)
      {    
        var productId = $("#dproductselect option:selected").attr("class");  
        var finalstrig=productId.split(",");
    
        var select='';
        select+='<select class="test" multiple="multiple" name="dproduct_ids" id="dproduct_ids">';
    
        for(i=0;i<finalstrig.length;i++)
        {
           //CREATE ONE AJAX CALL TO CHECK IS THIS PRODUCT ID SHOW IN DROPDOWN OR NOT 
           var returnresult = 0;
           var url="SOMEURL?p_id="+finalstrig[i]; 
           var request = jQuery.ajax( {
                url: url ,
                type: 'POST',                      
            } );
    
            request.done( function (result)
            {  
               returnresult = 1;
    
            });
            request.fail( function ( error )
            {
                console.dir(error);             
            } );
    
          if(finalstrig[i]!=0 && returnresult)
          {
            select +='<option value="'+finalstrig[i]+'">'+finalstrig[i]+'</option>';
          }
        }
        select +='</select>';   
        document.getElementById('productnumbers').innerHTML =select;
        (function($) {
        $(function() {
            $('.test').fSelect();
        });
    })(jQuery);
    
      }