SugarCRM 7.6 How to develop dependent drop down

HI,

How to develop dependent drop down . I stuck in back-bone js that how i can get value of drop down.

and according to that i want populate another  drop down.

Thank you

Parents
  • Hi Shiv Gawande

    This post may help you.

    If you want to do it from js file then do to so;

    create-actions.js file

    under initialize: function()

    After this._super("initialize", [options]);

    this.events['change input[name=your-fieldname]'] = 'getOptValue';

    Then under getOptValue function :

    getOptValue: function (elem) {
      var firstDropValue = this.model.get('firstDropFieldName');
      $.ajax({
      type: "POST",
      data: {firstdpvalue: firstDropValue},
      url: 'get_secondDrop_list.php', // In this file get the value of first dropdown based on that get second dropdown values and return data in json
      dataType: 'json',
      success: function(json) {
      var $el = $("#SecondDropFieldID");
      $el.empty(); 
      $el.append($("<option></option>").attr("value", '').text('Please Select'));
      $.each(json, function(value, key) {
      $el.append($("<option></option>").attr("value", value).text(key));
      });
      }
      });
    }
    
    
    

    Hope this Helps

    Best Regards

    S Ramana Raju

Reply
  • Hi Shiv Gawande

    This post may help you.

    If you want to do it from js file then do to so;

    create-actions.js file

    under initialize: function()

    After this._super("initialize", [options]);

    this.events['change input[name=your-fieldname]'] = 'getOptValue';

    Then under getOptValue function :

    getOptValue: function (elem) {
      var firstDropValue = this.model.get('firstDropFieldName');
      $.ajax({
      type: "POST",
      data: {firstdpvalue: firstDropValue},
      url: 'get_secondDrop_list.php', // In this file get the value of first dropdown based on that get second dropdown values and return data in json
      dataType: 'json',
      success: function(json) {
      var $el = $("#SecondDropFieldID");
      $el.empty(); 
      $el.append($("<option></option>").attr("value", '').text('Please Select'));
      $.each(json, function(value, key) {
      $el.append($("<option></option>").attr("value", value).text(key));
      });
      }
      });
    }
    
    
    

    Hope this Helps

    Best Regards

    S Ramana Raju

Children