lundi 4 mai 2020

Show the value of all selected checkboxes on top of the list

I want to get the whole values of checkboxes, which are checked, and show them at the top of the list. I have written everything in JS and I need to bind these values at the end to Popup. Hier is my code that shows when a button is clicked a popup will be appeared with a list of checkboxes:

btnRegelnExisted.onclick = async () => {


      const result = await api.getPolicies()

      const ergebnis = result.data.policies.map(policy => policy.name);

      let DivNames = document.createElement('div');
      DivNames.id = 'divMDSnames';
      let titleNameListMDS = document.createElement('p');
      titleNameListMDS.textContent = "Regel zuordnen:";
      titleNameListMDS.id = "TitleMDSname";
      DivNames.append(titleNameListMDS);

      let DivInnerNames = document.createElement('div');
      DivInnerNames.id = "DivInnernames";
      var ul = document.createElement('ul');
      DivInnerNames.appendChild(ul);
      DivNames.append(DivInnerNames);

      ergebnis.forEach(function (ergebnis) {
        var ValueOfName = document.createElement('li');
        var checkboxvalue = document.createElement('input');
        checkboxvalue.type = 'checkbox';
        ValueOfName.id = 'msdNameValue';
        ul.appendChild(ValueOfName);
        ValueOfName.append(checkboxvalue);
        ValueOfName.innerHTML += ergebnis;

      });

      layer.bindPopup(DivNames).openPopup();
    }

And I also attach a screenshot from the current result.

enter image description here




Aucun commentaire:

Enregistrer un commentaire