0

I have got this error" Cannot read property 'value' of null" and not sure whats wrong with my code? I have some inputs in my popup that users can edit them, and I want to save edits.

view.popup.on("trigger-action", function(event) {
if (event.action.id === "edit") {

setupEditing(searchResults[arraypos]);
console.log(this);
}
if (event.action.id === "update") {

editFeature.attributes["common_name"] = document.getElementById('commonName').value;
editFeature.attributes["scientificname"] = document.getElementById('sientificName').value;
editFeature.attributes["family"] = document.getElementById('family').value;

var edits = {
updateFeatures: [editFeature]
};
console.log(editFeature.attributes);
tree.applyEdits({updates:[edits]}).then(response => console.log(response));
}
});
}

and here are my ids that seems correct:

function setupEditing(sr) {
     esripopupcontent = document.getElementsByClassName('esri-popup__content')[0];
   esripopupcontent.innerHTML = "<table><tr><td>Common Name</td><td><input value=" + commonname + " id= commonName/></td></tr><tr><td>Scientific Name</td><td><input value=" + scientificname + " id= sientificName /></td></tr><tr><td>family</td><td><input value="+ family + " id= family/></td></tr></table>";
Anne
  • 1
  • 1
  • 1
    One of your element ids is not on the page, or misspelled...the ".value" call is being called on null ... ie, it can't find the object by id...."document.getElementById('sientificName').value"? – circusdei Jun 19 '17 at 19:12
  • 3
    1. Please list the full, exact error message. 2. Provide your HTML – Korgrue Jun 19 '17 at 19:12
  • One of elements you have tried to "getById" does not exist. Without additional information I will not be able to tell you which one, but your browser console should tell you that. – M. Prokhorov Jun 19 '17 at 19:13
  • This is the full error: test55.html:309 Uncaught TypeError: Cannot read property 'value' of null at HTMLDivElement. (test55.html:309) at Function.g.emit (init.js:53) at Object.emit (init.js:685) at Object. (MapView.js:149) at Object.l [as ontrigger-action] (init.js:63) at Function.g.emit (init.js:51) at Function.g.emit (init.js:53) at Object.emit (init.js:62) at Object.e (init.js:216) at Object.emit (init.js:374) – Anne Jun 19 '17 at 19:17

0 Answers0