glevine
08-24-2005, 08:13 PM
I am currently trying to write a page to display data that is stored in external js files. On the first page, a user enters
an id number and that is sent to a new page using a query string. the id # is then concatenated with 2 other pieces of data
to form a string which represents the src of the external js file. I then need to grab data from a 4 dimensional array that
resides in the js file, in the form:
var rawStats=[
["0001","Y","Name Name","2005","R"],
["0001","Y","Name Name","2005","R"],
["0001","Y","Name Name","2005","R"],
[]
];
rawBatting.length=rawBatting.length-1; //to make up for that last empty row
I only need to access the name at this point, but I'm really not sure how to do that. All of my google searches and random
trials haven't turned up anything yet. Thanks in advance for any help you can give me.
Here is the page I currently have written to display data:
<html>
<head>
<title>Batter</title>
</head>
<body>
<p><script language="JavaScript"><!--
function GetParam(param)
{
var start=location.search.indexOf("?"+param+"=");
if (start<0) start=location.search.indexOf("&"+param+"=");
if (start<0) return ' ';
start += param.length+2;
var end=location.search.indexOf("&",start)-1;
if (end<0) end=location.search.length;
var result=location.search.substring(start,end);
var result=' ';
for(var i=start;i<=end;i++)
{
var c=location.search.charAt(i);
result=result+(c=='+'?' ':c);
}
return unescape(result);
}
var jsfile=' ';
var jsfilesrc=' ';
if (location.search!='')
{
document.write('This page was opened with the following data:<br>');
document.write('Param id = ');
document.write(GetParam('id'));
jsfile='p'+GetParam('id')+'Bat.js';
document.write('<br>JS File = '+jsfile);
jsfilesrc='url/to/location/of/js/files'+jsfile;
document.write('<br>jsfilesrc = '+jsfilesrc);
}
// --></script></p>
<p>
<script language="JavaScript" src=jsfilesrc><!--
//HERE'S WHERE I BELIEVE A FUNCTION NEEDS TO GO TO ACCESS DATA
// --></script>
</p>
</body>
</html>
an id number and that is sent to a new page using a query string. the id # is then concatenated with 2 other pieces of data
to form a string which represents the src of the external js file. I then need to grab data from a 4 dimensional array that
resides in the js file, in the form:
var rawStats=[
["0001","Y","Name Name","2005","R"],
["0001","Y","Name Name","2005","R"],
["0001","Y","Name Name","2005","R"],
[]
];
rawBatting.length=rawBatting.length-1; //to make up for that last empty row
I only need to access the name at this point, but I'm really not sure how to do that. All of my google searches and random
trials haven't turned up anything yet. Thanks in advance for any help you can give me.
Here is the page I currently have written to display data:
<html>
<head>
<title>Batter</title>
</head>
<body>
<p><script language="JavaScript"><!--
function GetParam(param)
{
var start=location.search.indexOf("?"+param+"=");
if (start<0) start=location.search.indexOf("&"+param+"=");
if (start<0) return ' ';
start += param.length+2;
var end=location.search.indexOf("&",start)-1;
if (end<0) end=location.search.length;
var result=location.search.substring(start,end);
var result=' ';
for(var i=start;i<=end;i++)
{
var c=location.search.charAt(i);
result=result+(c=='+'?' ':c);
}
return unescape(result);
}
var jsfile=' ';
var jsfilesrc=' ';
if (location.search!='')
{
document.write('This page was opened with the following data:<br>');
document.write('Param id = ');
document.write(GetParam('id'));
jsfile='p'+GetParam('id')+'Bat.js';
document.write('<br>JS File = '+jsfile);
jsfilesrc='url/to/location/of/js/files'+jsfile;
document.write('<br>jsfilesrc = '+jsfilesrc);
}
// --></script></p>
<p>
<script language="JavaScript" src=jsfilesrc><!--
//HERE'S WHERE I BELIEVE A FUNCTION NEEDS TO GO TO ACCESS DATA
// --></script>
</p>
</body>
</html>