这是一个学校项目!我只有几周的时间来学习 JavaScript - 我正在尽我最大的努力学习它,但我真的需要帮助,所以我再次向那些精通和知识渊博的人寻求帮助......
没有代码错误出现,并且不确定为什么这不会显示在该项目的“管理”页面上的 ALERT 窗口中。任何想法或想法将不胜感激!谢谢...
这是 JSFiddle - http://jsfiddle.net/qux3K/1/
这是代码:
// Chapters 7 & 8 - store.js
// 此脚本创建一个“假”数据库,将可用的 CD 存储在我们的音乐商店收藏中。
// Function called when page is loaded.
// Function creates a new object.
function process() {
'use strict';
// Create a new array:
var cd = new Array ([
{"cd":0, "item":"001", "title": "Total Life Forever", "artist": "FOALS", "price": "$14.99", "released": "March, 2009", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":1, "item":"002", "title": "Bein Love", "artist": "Locksley", "price": "$14.99", "released": "April, 2012", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":2, "item":"003", "title": "Privileged", "artist": "Nick Moss", "price": "$14.99", "released": "June, 2011", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":3, "item":"004", "title": "Asondeguerra", "artist": "Juan Louis Guerra", "price": "$14.99", "released": "September, 2013", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":4, "item":"017", "title": "Way Out Here", "artist": "Josh Thompson", "price": "$14.99", "released": "August, 2010", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":5, "item":"018", "title": "Tremolo", "artist": "The Pines", "price": "$14.99", "released": "January, 2007", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":6, "item":"019", "title": "Live From Freedom Hall", "artist": "Lynyrd Skynyrd", "price": "$14.99", "released": "June, 2010", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":7, "item":"020", "title": "Achin' & Shakin'", "artist": "Laura Bell Bundy", "price": "$14.99", "released": "July, 2013", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":8, "item":"021", "title": "Here I Am", "artist": "Marvin Sapp", "price": "$14.99", "released": "November, 2011", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":9, "item":"022", "title": "Just James", "artist": "J Moss", "price": "$14.99", "released": "March, 2011", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
{"cd":10, "item":"013", "title": "Tom Petty - Live", "artist": "Tom Petty", "price": "$14.99", "released": "May, 2010", "tracks": "Track Listing" {1,2,3,4,5,6,7,8,9,10,11,12}, "quantity": "1"}
]);
// Function to call titles in an alert box
alert('CD titles available are' + cd({title:"0,1,2,3,4,5,6,7,8,9,10"}));
// End of alert.
}
// End of process() function.
// Initial setup:
function init() {
'use strict';
document.getElementById('theForm').onsubmit = process;
} // End of init() function.
window.onload = init;