22
February

0 Comments | 0 Shares | Urdhva Tech | Tags: Dropdown

Greetings!

At times, I have ran into requirement of getting drop down options of a field in Javascript in SugarCRM.

Here is the code that will get you options as an array.

For example, you want to fetch values of case_status_dom, the code will be,


var statusOptions = SUGAR.language.languages.app_list_strings['case_status_dom'];

alert(statusOptions['Closed']); // alert a key and you will have its value

// You can loop through them to create an dropdown in JS itself.

var status_dd = "<select name= 'status' id='status'>";

for(var key in statusOptions){ 

    // Here "key" gives the key of options and "statusOptions[key]" gives the value of it. 
    status_dd += '<option value="'+key+'">'+statusOptions[key]+'</option>';    
}
status_dd +="</select>";



Hope this helps!

Feel free to drop your valuable comments below.

Download attachments:
Comments
  • No Comments Found.
Post your comment