Hi everyone,
First, I am not a programmer so be gentile. I need some help getting data from a url and placing it into a table. I am trying to get the daily threshold securities list that is published daily on the nasdaq site. The data published today is for yesterday's threshold securities. The url changes everyday according to the date eg:
http://www.nasdaqtrader.com/dynamic/symdir/regsho/nasdaqth20100222.txt. The script that I managed to hack together does get the correct url everyday, but I am unable to insert the data into a dynamically created table. Here is what I have so far:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>ShoList</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
//create the Cross-browser XMLHttpRequest object
function getFile(pURL,pFunc) {
if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
xmlhttp=new XMLHttpRequest();
eval('xmlhttp.onreadystatechange='+pFunc+';');
xmlhttp.open("GET", pURL, true); // leave true for Gecko
xmlhttp.send(null);
} else if (window.ActiveXObject) { //IE
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
if (xmlhttp) {
eval('xmlhttp.onreadystatechange='+pFunc+';');
xmlhttp.open('GET', pURL, false);
xmlhttp.send();
}
}
}
function makeTable() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status==200) {
var tmpArr=xmlhttp.responseText.split('\n');
var out='<table id="theListTable" border="1" width="800" bordercolor="#DBDBDB" cellpadding="2" style="border-collapse:collapse;">';
var tmp;
var val;
var txt;
var strText;
for (var idx=0;idx<tmpArr.length;idx++) {
tmp=tmpArr[idx].split('|');
/* out += '<tr><td>'+tmpArr[idx]+'</td></tr>';*/
strText= '<tr>';
for (var intTmp=0;intTmp<tmp.length;intTmp++)
{
if (intTmp<5){
txt = tmp[intTmp].replace('"','');
strText= strText + '<td>'+txt+'</td>';
}
}
/*{
if (intTmp<tmp.length -1){
if (intTmp<5){
txt = tmp[intTmp].replace('"','');
strText= strText + '<td>'+txt+'</td>';
}
else
txt = tmp[intTmp].replace('"','')
txt=''
strText= strText + '<td>'+txt+'</td>';
parent.shoDate=txt
}
}*/
out += strText + '</tr>';
}
out += '</table>';
document.getElementById('theList').innerHTML=out;
}
}
}
</script>
<script type="text/javascript">
function getFileUrl(){
/*First, get the current date*/
var currentTime = new Date();
/*because shoLists are published only at midnight during the workweek, we must subtract 1 from the day
In the case of Sunday, we subtract two, and Monday, subtracdt 3 in order to get Friday's list*/
var intNB = 1
if(currentTime.getDay() == 0)
{
intNB=2;
}
else if(currentTime.getDay() == 1)
{
intNB = 3;
}
else
{
intNB = 1;
}
/*We now need to subtract the number from the day to get the right date (Year, month, and day)*/
var day = currentTime.getDate() - intNB;
var month = currentTime.getMonth() + 1;
var year = currentTime.getFullYear();
/*If the day is less than ten, we must add a 0 to make the day a two digit number*/
if (day<10)
day="0"+ day
if (month<10)
month="0"+ month
/*Finally, we must put it all togther to create the proper URL to get the shoList file */
var shoDate=year + '' + month + '' + day
var strUrl='http://www.nasdaqtrader.com/dynamic/symdir/regsho/nasdaqth'
var strTxtUrl=strUrl+shoDate+'.txt'
/*
getFileURL=strTxtUrl
TEST*/
document.write(strTxtUrl)
}
</script>
<style type="text/css">
<!--
/* CSS Document */
.contenttext {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: normal;
text-transform: none;
color: #333333;
}
.titletext {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
color: #333333;
}
-->
</style>
</head>
<body onload="getFile(getFileUrl(),'makeTable');">
<div class="contenttext" id="theList">Loading...</div>
</body>
</html>