Skip to content

Instantly share code, notes, and snippets.

@TheOpenDevProject
Last active December 27, 2015 07:04
Show Gist options
  • Save TheOpenDevProject/64045eca933f32ee4c0f to your computer and use it in GitHub Desktop.
Save TheOpenDevProject/64045eca933f32ee4c0f to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<head>
<title>HTML5 Generators - RootZero</title>
<!--NO-CACHE-VERSIONING-->
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<script>
$(document).on("ready",function(){
$("#myFile").on("change",function(e){
var fileDisplayArea = $('#fileDisplayArea');
var file = $('#myFile')[0].files[0];
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function(ev){
console.log(ev.target.result);
parseAndBuild(ev.target.result);
};
})
});
var parseAndBuild = function(result){
var opts = result.split(' ');
var DOMElement = "";
DOMElement += "<select id='fun'>";
opts.forEach(function(o){
DOMElement += "<option>" + o + "</option>";
});
DOMElement += "</select>";
$("body").append(DOMElement);
}
</script>
<body>
File:<input id="myFile" type="file"/>
<div id="fileDisplayArea">
</div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment