Tell me, please, how to add lines from a file to such an element and in general, is it possible:
ListBox (select) example enter image description here

    1 answer 1

    Without javascript can not do.
    To read the file, you can use this answer by adding an item to Select w3schools .
    Each new element in the file must be accompanied by a space.

     <!DOCTYPE html> <html> <body> <form> <select id="mySelect" size="8"> <option>Apple</option> <option>Pear</option> <option>Banana</option> <option>Orange</option> </select> </form> <br> <input type='file' accept='text/plain' onchange='openFile(event)'><br> <script> var openFile = function(event) { var input = event.target; var reader = new FileReader(); reader.onload = function() { var text = reader.result; add(text); }; reader.readAsText(input.files[0]); }; function add(text) { var x = document.getElementById("mySelect"); var arrText = text.split(' '); for (var i = 0; i < arrText.length; i++) { if (arrText[i] !== '') { var option = document.createElement("option"); option.text = arrText[i]; x.add(option); } } } </script> </body> </html> 

    • Thank you very much :) Already done on the server side is true, but this is a brilliant answer! - Flerry