AnsweredAssumed Answered

Domain as Drop down ArcGIS Javascript

Question asked by katroyer on Mar 7, 2016
Latest reply on Mar 7, 2016 by evtguy

I would really love to use the codedvalues from the domains I have set up in my database, but having a really hard time finding any working examples.  I have a tiled map service and a feature layer that I load and then the following code runs.  Most of the time my tiled map service does not load and the drop down is not populated - however if I refresh the page, my tiled service will load and the drop down is populated.  What am I missing?

 

 

map.on("load", init);
    function init()
    {
        codedDomain("myFieldName","myDropDownID");
        
    }
    
    
    function codedDomain(fieldName,dropdown){
        var newDropdown= dom.byId(dropdown);
        var domain = fLayer.getDomain(fieldName);
        for (var i=0; i<domain.codedValues.length; i++)
        {
            if (i<domain.codedValues.length)
            {
                newDropdown[newDropdown.length]=new Option(domain.codedValues[i].name);    
            }
            
        }
    }

Outcomes