I have the following code. In that I am displaying normal text. In place of that I want to
load a local text file.
I am not able to load a local text file.
Here, I want to load the content of a.txt file from my home folder in the textarea on selection of option a. And so on.
<html>
<body>
<div class="left">
File Display
<p>
<select class="x" onchange="showfile(this);">
<option selected="selected" value="" id="Templates">Please select an option</option>
<option>a</option>
<option>b</option>
<option>c</option>
<option>d</option>
</select>
</p>
<p>
<textarea cols="30" rows="20" readonly="readonly" id="textar">
</textarea>
</p>
</div>
<script>
function showfile(sel){
files =[ "",
/*option a*/
"display file a.txt ",
/*option b*/
" display file b.txt ",
/*option c*/
" display file c.txt",
/*option d*/
"display file d.txt", ];
srcfile = files [sel.selectedIndex];
if (srcfile != undefined && srcfile != "") {
document.getElementById('textar').innerHTML= srcfile;
}
}
</script>
</body>
</html>