[thelist] JavaScript Array and Split

Christie Mason cmason at managersforum.com
Sun Feb 11 17:21:14 CST 2007


I've been attempting to resolve for a long while, and I could do this if it
was coming from a database, but I'm gotten myself so confused I don't even
know what to search for anymore.

There are various external js files that each have varying cData arrays that
look like this
cData=new Array()
cData[0]='Auto
Order|../../courseid12663/AutoOrder/autoordercm.html|772|520|0|00:00:0||'
cData[1]='Steep Slope Roofing Basics
Test|../../courseid12663/SteepSlopeRoofingBasicsTest/mcq_ssbasics_cm.html|77
2|520|0|00:00:0||'
cData[2]='TimeCalc Payroll
Database|../../courseid12663/TimeCalcPayrollDatabase/ssrpimctest.html|772|52
0|0|00:00:0||'

I found this example which close to what I need to do.
var mylink;
mylink = new Array;

mylink[0] = "KSU|http://www.ksu.edu";
mylink[1] = "OU|http://www.ou.edu";
mylink[2] = "Google|http://www.google.com";
mylink[3] = "Yahoo|http://www.yahoo.com";
mylink[4] = "MSN|http://www.msn.com";

var content = "";

for(i=0; i<mylink.length; i++)
{ var linksplit = mylink[i].split("|");
content+= "<p>";
content+="<a href=' "+linksplit[1]+" '>";
content+=linksplit[0];
content+="</a>";

}
document.write(content);

EXCEPT it needs to read the cData array from the external js file to
generate the list of links.

I'll probably be very embarrased by how stupid I'm being, but I'm defeated
and I admit it.

C. Mason




More information about the thelist mailing list