AnsweredAssumed Answered

How do I get value of a node to use as a variable to set a default value for an address search?

Question asked by csergent08 Champion on Aug 12, 2015
Latest reply on Aug 28, 2015 by RWinter85

I have the following block of code where I ewant to set the node value based on the focus event so that I can reuse this block of code. It works when I use this line: node = document.getElementById('ownerAddress');

but not when I try to set node to a variable. I also have node declared as a global variable. I thought I could access it since I returned the value in my getElementId function and then use the node.value in the checkAddress function, but there is no value at that time. What am I doing wrong in this block?

 

 

 on(document.getElementById('ownerAddress'), 'focusout', checkAddress);


                 on(document.getElementById('ownerAddress'), 'focusin', getElementId);


                 function getElementId() {
                     console.log(document.activeElement.id);
                     
                     node = document.activeElement.id;
                     console.log(node);
                     return node;
                 }




                 function checkAddress() {
                     var locator = new Locator("http://maps.decaturil.gov/arcgis/rest/services/Public/WebAddressLocator/GeocodeServer");
                     //console.log(document.getElementById('ownerAddress').value);
                     //node = document.getElementById('ownerAddress');
                     // according to your service it takes Single Line
                     var params = {
                         "Single Line Input": node.value
                     };

Outcomes