Robert Scheitlin, GISP helped me by providing this example to return an array based on value: JS Bin - Collaborative JavaScript Debugging
But how do I get each name and value in my array?
In this example a supportId of 691 is selected. I have a form that I want to update only one set of values at at time, so how do get just the name;
SIGNID and the value of 1169 so that I may set SIGNID's value to 1169 on the form. I basically want to update my form with all the values in the first element of the array, but I am not sure how to select JSON items. The following items are in my array and I will want to replace each as the user click previous or next.
It is basically returning feature Array.
Line that says:
resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>");
change it to
featureAttributes['OBJECTID'];
this would return all the OBJECTIDs. for accesing VISIBILITY of all items use this
featureAttributes['VISIBILITY'];
This is how you access it.
If you want to update control with specific OBJECTID:
Change line that says:
resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>");
For example we want to change SITEOBS from clear to Unclear of OBJECTID 9265
if(featureAttributes['OBJECTID'] == 9265) {
featureAttributes['SITEOBS'] = 'UnClear';
}
To update a control like text box:
if(featureAttributes['OBJECTID'] == 9265) {
document.getElementById('siteobsTxt').innerText = featureAttributes['SITEOBS'] ;
}
Hope it helped.
This helps if I want to manually enter information in. I figured out what I needed to do. I needed to return the attr which is the attribute or name and the feature attribute which is the value of the attribute. I used the following code to do this:
console.log("Attribute: " + attr); console.log("Feature Attribue: " + featureAttributes[attr]);