I want an associative array object of the string of an HTML element's name to the hidden input element. Like so...
var fieldNames2inputElements = {
'FirstName' : document.getElementsByName('FirstName')[0],
'LastName' : document.getElementsByName('LastName')[0],
...
};
I'm already shaking my head at myself, knowing there's got to be a more DRY way of doing this. Any suggestions? How do I use the string key of an associative array as a parameter of something in the value for that key?
BTW: I don't have control of the hidden input elements having this name attribute versus an id or some other way of selecting it.
document.querySelectorAll()operations, one for each firstname and lastname. Then usingArray.prototype.map.call(firstNames, c => {...});and then the same for thelastNamesis one way of doing this job.