I have been able to work through making an array for this application, the problem is now I need to display this array as a value in an input on a page. I have tried multiple things to be able to parse this data to one input form as a value. There are multiple inputs on this page, so I'm not sure I have to do a loop. That is why I wanted to use the array item as the item shown. Can someone tell me what I may be doing wrong? Thank you in advance for your time.
In .js file
function pEdit() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var pInfo = this.responseText.split('\r');
var out = [];
for (var i = 0; i < pInfo.length; i++) {
out.push(pInfo[i]);
var pn = pInfo[1] ;
}
}
};
xhttp.open("GET", "http://127.0.0.1:8080/PartInfo.txt", true);
xhttp.send();
}
On Specific HTML Page
<body onload="pEdit();">
<script>
document.getElementById('eName').value = pEdit('pn') ;
</script>
I have tried to decalare both pInfo[array#] as well as just pn. I am expecting the value of the specific array to show in the form.