Q:

Text to Html list

I want to make a html which will auto get the information for a *.txt file
something1
something2
something3

and output into this html file
 <!DOCTYPE html>
    <html>
    <head>
        <title>List</title>
    </head>
    <body>
            <ul>
                #here to output#
            </ul>
    </body>
    </html>

I prefer to use JavaScript.  Some help is appreciated. 

A:

You have to request the file using AJAX call. Then you need to iterate through each line of response and generate DOM element (li in this case) and input line inside of it. After that insert each li element into your ul list.
You can achieve it using jQuery as you are probably new to JavaScript it's probably the easiest way.
What you need to do is request the file first:
$.ajax('url/to/your/file', {
    success: fileRetrieved
});

Now after the file is retrieved jQuery will call fileRetrieved method, so we have to create it:
function fileRetrieved(contents) {
    var lines = contents.split('\n');
    for(var i = 0; i < lines.length; i += 1) {
        createListElement(lines[i]);
    }
}

Now for each line from the file function fileRetrieved will call createListElement function passing line of text to it. Now we just need to generate the list element and inject it into DOM.
function createListElement(text) {
    var into = $('ul');
    var el = $('<li></li>').html(text);
    el.appendTo(into);
}

Of course you don't want to retrieve into element each time createListElement is called so just store it somewhere outside the function, it's your call, I'm just giving you the general idea.
Here is an example of the script (without AJAX call of course as we can't simulate it):

var into = $('#result');

function fileRetrieved(contents) {
  var lines = contents.split('\n');
  for (var i = 0; i < lines.length; i += 1) {
    createListElement(lines[i]);
  }
}

function createListElement(text) {
  var el = $('<li></li>').html(text);
  el.appendTo(into);
}

var text = $('#text').html();
fileRetrieved(text);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<!-- This element simulates file contents-->
<pre id="text">
  fdsafdsafdsa
  fdsafd
  safdsaf
  dsafdsaf
  dsafdsafds
  afdsa
</pre>

<div id="result"></div>

