0

I have this javascript that retrieves a list of values from a html form, but I need a button click event to display this output as a custom window with the retrieved (not alert) list of values selected on the form on separate lines

    function printChecked(){
        var items=document.querySelectorAll('[name="option"], [name="selectedfeaturem"], [name="selectedfeaturep"], [name="selectedsoftware"], [name="selectedfeature"]');
        var selectedItems="";
        for(var i=0; i<items.length; i++){
            if(items[i].checked==true)
                selectedItems+=items[i].value+"\n";
        } 
return selectedItems;
    }

It works in a div within the form but I need it as a custom Popup window (could be css formatted) but it fails when I attempt to add it to these div. This div works on the form as a standalone code but I need to combine both set of codes so that on click the below tab will display the above list within the pop-up window.

<p>This is the main content to display  <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">here</a></p>
        <div id="light" class="white_content">This is the lightbox content. <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
        <div id="fade" class="black_overlay"></div>
Samuel
  • 7
  • 3
  • Can you provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). A working code snippet is preferred. – myfunkyside Jul 01 '20 at 01:36
  • @myfunkyside My aim is for button "Display Function>>PrintChecked()" to display the checked items. Here is the link https://jsfiddle.net/samkvikna/pengxv5h/15/ – Samuel Jul 01 '20 at 19:56
  • Not sure if this is the cause of your problem, didn't have time to properly look at your code yet, but you are using associative arrays all wrong, as in, it can't be done in JavaScript. Read [**this answer**](https://stackoverflow.com/a/38339645) and [**this answer**](https://stackoverflow.com/a/37516003) carefully (and also have a look at the two questions and the other answers) and you'll understand. – myfunkyside Jul 02 '20 at 00:17

0 Answers0