AnsweredAssumed Answered

Dojo.byID/registry.ById textbox not visible inside a function

Question asked by on Jan 26, 2017
Latest reply on Jan 27, 2017 by

I've got a simple webpage where you enter in street, city, and it hits a geocoding service. The service returns X,Y and I'm trying to write those values into a "dijit/form/TextBox". For testing I am able to set the street, city textboxes using registry.byId and pass the value to the service. The function that parses out the returned X,Y is not able to see the X,Y textboxes.


require([ 'esri/map',"dojo/on","dojo/parser","dijit/registry","dojo/ready","dojo/dom","dijit/form/Button","dijit/form/TextBox", 'esri/geometry/Point','esri/symbols/SimpleMarkerSymbol','esri/Color','esri/graphic',"esri/symbols/PictureMarkerSymbol",'dojo/_base/xhr', 'dojo/domReady!' ], function (Map, on, parser, registry, ready, dom, Point, SimpleMarkerSymbol, Color, Graphic, PictureMarkerSymbol, xhr) { var map = new Map("map", { center: [-56.049, 38.485], zoom: 3, basemap: "streets" });
parser.parse(); registry.byId("txtbx1").set("value", "800 n Pearl St");  //<<< This works and sets the valueregistry.byId("txtbx2").set("value", "Albany");  //<<< This works and sets the value// So I take the values from the testbox, hit a geocoding service and it returns a x,y// The function below sohow the JSON return from the service as I pull out the X,Y.// Now I was trying to put the X,Y back into a dojo textbox but inside this function // I'm not able to see/hit the textbox//SAM Servicefunction SFunction(response) { var obj1 = JSON.parse(response); console.log(obj1);  var Sx= obj1.candidates[0].location.x;  //returns -73.7363046904528 var Sy= obj1.candidates[0].location.y;  //return 42.67997793613371 console.log(Sx +", "+Sy); dojo.byId("txtbx4").innerHTML=Sy;  //Cannot set property 'innerHTML' of nullregistry.byId("txtbx4").set("value", Sy);  //Cannot read property 'set' of undefineddocument.getElementById("txtbx4").value = Sy;  //Cannot set property 'value' of null