I am instructed to add a function named showTable() with no parameters that writes some HTML table code to the document (I have done this I believe). I then have to create a table row for each person listed in the lastName array, create a for loop looping through each entry, writing the HTML code
<tr> <td>date</td> <td class='amt'>amount</td> <td>firstName</td> <td>lastName</td> <td>street <br /> city, state, zip </td> </tr>
where date, amount, firstName, lastName, street, city, state, zip are the items from the date, amount, firstName, lastName, street, city, and zip arrays.
Here is my table.js I coded so far:
function showTable() {
document.write("<table id='contributors'>")
document.write("<thead>")
document.write(" <tr>")
document.write("<th>Date</th><th>Amount</th>")
document.write("<th>First Name</th><th>Last Name</th>")
document.write("<th>Address</th>")
document.write(" </tr>")
document.write(" </thead>")
document.write(" <tbody>")
var lastName= [date, amount, firstName, lastName, street, city, state, zip];
document.write(" <tr>")
for var i = 0; i < lastName.length; i++) {
document.write("<td>" + lastName[i] + "</td>")
}
document.write(" </tr>")
}
and the april.js provided by the instructor:
firstName = new Array(); lastName = new Array(); street = new Array(); city = new Array(); state= new Array(); zip = new Array(); amount = new Array(); date = new Array() firstName[0]="Nina"; lastName[0]="Largent"; street[0]="88 Regal Lane"; city[0]="Williamsburg"; state[0]="KY"; zip[0]="40769"; amount[0]=175; date[0]="2015-04-18"; firstName[1]="Morris"; lastName[1]="Hawkins"; street[1]="404 Barrow Street"; city[1]="London"; state[1]="KY"; zip[1]="40742"; amount[1]=75; date[1]="2015-04-18"; firstName[2]="Monica"; lastName[2]="Lang"; street[2]="743 Stawlings Drive"; city[2]="Danville"; state[2]="KY"; zip[2]="40423"; amount[2]=150; date[2]="2015-04-16"; firstName[3]="William"; lastName[3]="McKnight"; street[3]="102 Maple Lane"; city[3]="Danville"; state[3]="KY"; zip[3]="40423"; amount[3]=150; date[3]="2015-04-15"; firstName[4]="Latrina"; lastName[4]="Hults"; street[4]="750 Whitehall Road"; city[4]="London"; state[4]="KY"; zip[4]="40742"; amount[4]=280; date[4]="2015-04-14"; firstName[5]="Danny"; lastName[5]="Shamblin"; street[5]="123 Smith Drive"; city[5]="Owensboro"; state[5]="KY"; zip[5]="42303"; amount[5]=80; date[5]="2015-04-13"; firstName[6]="Tina"; lastName[6]="Ammons"; street[6]="888 Evans Way"; city[6]="Williamsburg"; state[6]="KY"; zip[6]="40769"; amount[6]=50; date[6]="2015-04-13"; firstName[7]="Joanne"; lastName[7]="Fine"; street[7]="210 Bowling Terrace"; city[7]="Williamsburg"; state[7]="KY"; zip[7]="40769"; amount[7]=155; date[7]="2015-04-11"; firstName[8]="Charlotte"; lastName[8]="Foulk"; street[8]="109 South Road"; city[8]="Danville"; state[8]="KY"; zip[8]="40423"; amount[8]=90; date[8]="2015-04-10"; firstName[9]="Candice"; lastName[9]="Alfaro"; street[9]="108 Atwood Avenue"; city[9]="Owensboro"; state[9]="KY"; zip[9]="42303"; amount[9]=450; date[9]="2015-04-08"; firstName[10]="Kristi"; lastName[10]="Laine"; street[10]="512 North Lane"; city[10]="Williamsburg"; state[10]="KY"; zip[10]="40769"; amount[10]=275; date[10]="2015-04-08"; firstName[11]="Elisabeth"; lastName[11]="Carbone"; street[11]="381 Main Street"; city[11]="London"; state[11]="KY"; zip[11]="40742"; amount[11]=210; date[11]="2015-04-07"; firstName[12]="James"; lastName[12]="Larsen"; street[12]="212 Rawlings Way"; city[12]="Jackson"; state[12]="KY"; zip[12]="41339"; amount[12]=175; date[12]="2015-04-07"; firstName[13]="Ralph"; lastName[13]="Thornton"; street[13]="444 Smith Drive"; city[13]="Owensboro"; state[13]="KY"; zip[13]="42303"; amount[13]=50; date[13]="2015-04-07"; firstName[14]="Robin"; lastName[14]="Witt"; street[14]="78 Norland Pines"; city[14]="London"; state[14]="KY"; zip[14]="40742"; amount[14]=175; date[14]="2015-04-07"; firstName[15]="Alex"; lastName[15]="Ruiz"; street[15]="102 Sunset Road"; city[15]="Jackson"; state[15]="KY"; zip[15]="41339"; amount[15]=150; date[15]="2015-04-06"; firstName[16]="Callie"; lastName[16]="Rudy"; street[16]="3 Sunset Road"; city[16]="Jackson"; state[16]="KY"; zip[16]="41339"; amount[16]=55; date[16]="2015-04-06"; firstName[17]="Michael"; lastName[17]="Harrell"; street[17]="125 Sunset Road"; city[17]="Jackson"; state[17]="KY"; zip[17]="41339"; amount[17]=75; date[17]="2015-04-06"; firstName[18]="Edgar"; lastName[18]="Morales"; street[18]="387 North Lane"; city[18]="Williamsburg"; state[18]="KY"; zip[18]="40769"; amount[18]=150; date[18]="2015-04-05"; firstName[19]="Arlene"; lastName[19]="Lutz"; street[19]="7888 Clear View Drive"; city[19]="Danville"; state[19]="KY"; zip[19]="40423"; amount[19]=175; date[19]="2015-04-05"; firstName[20]="Earl"; lastName[20]="Holmes"; street[20]="1001 Rawlings Way"; city[20]="Jackson"; state[20]="KY"; zip[20]="41339"; amount[20]=700; date[20]="2015-04-04"; firstName[21]="Bernice"; lastName[21]="Drew"; street[21]="25 Main Street"; city[21]="London"; state[21]="KY"; zip[21]="40742"; amount[21]=190; date[21]="2015-04-04"; firstName[22]="Patrick"; lastName[22]="Granier"; street[22]="100 Atwood Avenue"; city[22]="Owensboro"; state[22]="KY"; zip[22]="42303"; amount[22]=135; date[22]="2015-04-03"; firstName[23]="Henry"; lastName[23]="Bailey"; street[23]="37 East Maple Street"; city[23]="Danville"; state[23]="KY"; zip[23]="40423"; amount[23]=85; date[23]="2015-04-03"; firstName[24]="Ginny"; lastName[24]="Rainey"; street[24]="657 Dawson Lane"; city[24]="Danville"; state[24]="KY"; zip[24]="40423"; amount[24]=150; date[24]="2015-04-03"; firstName[25]="Ginny"; lastName[25]="Rainey"; street[25]="657 Dawson Lane"; city[25]="Danville"; state[25]="KY"; zip[25]="40423"; amount[25]=55; date[25]="2015-04-03"; firstName[26]="Basilia"; lastName[26]="Lu"; street[26]="851 Flad Court"; city[26]="Jackson"; state[26]="KY"; zip[26]="41339"; amount[26]=600; date[26]="2015-04-02"; firstName[27]="Livia"; lastName[27]="McKinnon"; street[27]="557 Ivy Avenue"; city[27]="Jackson"; state[27]="KY"; zip[27]="41339"; amount[27]=150; date[27]="2015-04-01";
I appreciate any guidance. Let me know if I explained it well enough...
- James

New Topic/Question
Reply


MultiQuote





|