1

I have a selection box with a possible total of 13 options and I'm trying to dump the contents into an object for easier selection. I figured I could use Object.assign(), but the ID's are not helpful to me on the backend because I'm still unsure of what the ID correlates to. Ideally I'd like the ID to match the selected value. How can I go about making the object key values match with the actual values?

The code looks sort of like this

function addFeature() {
    var confirm0 = document.getElementById("featureName").value;
    var select1 = document.getElementById("acctlist");
    var selected1 = []
    for (var i = 0; i < select1.length; i++) {
      if (select1.options[i].selected)
        selected1.push(select1.options[i].value);
    }
    var object = Object.assign({}, select1);

    var data = { featureName: confirm0, selectedAccts: object};
Robert
  • 809
  • 3
  • 10
  • 19

0 Answers0