gpt4 book ai didi

JavaScript 数组短路脚本

转载 作者:行者123 更新时间:2023-11-28 12:09:17 26 4
gpt4 key购买 nike

我正在用 javascript 创建一个巨大的数组...它有 4 层深,有很多元素长。我在运行时使用 php 创建它,以便页面上的所有内容都能顺利运行,无需执行任何查询。

但是,现在,我的数组遇到了一些问题,我的 html 文件没有看到数组后面列出的 javascript 函数。通过测试,我已经缩短了数组并使其能够工作,但我一生都无法弄清楚为什么它会以完整形式 chop 脚本的其余部分。

如果有任何答案可以告诉我,我将不胜感激A.如何使用Firebug查找问题(我对Firebug很陌生)或者B. 告诉我#$%^ 问题是什么!

我将在下面列出我的整个脚本(php 的输出)。有问题的数组是“inventoryNames”。我已经检查过问题是否出在括号的数量上,但我现在 99% 肯定是这个问题。如果我将其注释掉,一切都会正常。谢谢

<script type="text/javascript">

var inventoryNames =
Array(
Array(
Array(
Array("AC/DC", "Back in Black", "36", "VG++", "12", ""),
Array("AC/DC", "Back in Black", "37", "VG", "8", "")
),
Array(
Array("AC/DC", "Highway to Hell", "30", "VG++", "10", ""),
Array("AC/DC", "Highway to Hell", "38", "VG", "5", ""),
Array("AC/DC", "Highway to Hell", "35", "NM", "16", ""),
Array("AC/DC", "Highway to Hell", "39", "NM", "14", "")
)
),
Array(
Array(
Array("Al Green", "Call Me", "40", "G", "5", ""),
Array("Al Green", "Call Me", "31", "NM", "15", "")
),
Array(
Array("Al Green", "Let's Stay Together", "32", "NM", "12", ""),
Array("Al Green", "Let's Stay Together", "33", "VG++", "10", ""),
Array("Al Green", "Let's Stay Together", "34", "VG", "8", "")
)
),
Array(
Array(
Array("B.B. King", "Confessin' the Blues", "45", "VG++", "9", ""),
Array("B.B. King", "Confessin' the Blues", "42", "NM", "35", "")
),
Array(
Array("B.B. King", "Lucille", "43", "VG++", "14", "")
),
Array(
Array("B.B. King", "Singin' the Blues", "41", "NM", "16", "")
),
Array(
Array("B.B. King", "Sings Spirituals", "44", "VG++", "10", "")
)
),
Array(
Array(
Array("Bad Company", "Bad Company", "12", "G", "2", ""),
Array("Bad Company", "Bad Company", "13", "M", "38", "1st Edition"),
Array("Bad Company", "Bad Company", "14", "VG+", "8", ""),
Array("Bad Company", "Bad Company", "3", "VG++", "13", "")
)
),
Array(
Array(
Array("Bob Dylan", "Another Side of Bob Dylan", "48", "VG++", "20", "")
),
Array(
Array("Bob Dylan", "Blonde on Blonde", "50", "M", "35", "")
),
Array(
Array("Bob Dylan", "Highway 61 Revisited", "49", "NM", "25", "")
),
Array(
Array("Bob Dylan", "The Freewheelin' Bob Dylan", "46", "VG++", "13", "")
),
Array(
Array("Bob Dylan", "The Times They Are A-Changin'", "47", "NM", "25", "")
)
),
Array(
Array(
Array("Boston", "Boston", "52", "VG++", "12", ""),
Array("Boston", "Boston", "53", "VG++", "10", ""),
Array("Boston", "Boston", "51", "VG", "7", ""),
Array("Boston", "Boston", "23", "VG", "6", "")
)
),
Array(
Array(
Array("Charlie Parker", "Jazz at Massey Hall", "54", "NM", "42", "")
)
),
Array(
Array(
Array("Creedence Clearwater Revival", "Green River", "56", "VG++", "13", ""),
Array("Creedence Clearwater Revival", "Green River", "57", "NM", "16", ""),
Array("Creedence Clearwater Revival", "Green River", "55", "VG+", "10", "")
),
Array(
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "60", "NM", "15", ""),
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "114", "NM", "16", ""),
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "58", "G", "5", ""),
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "59", "VG", "7", "")
)
),
Array(
Array(
Array("Dave Brubeck", "Time Out", "61", "NM", "18", ""),
Array("Dave Brubeck", "Time Out", "62", "VG+", "10", "")
)
),
Array(
Array(
Array("David Allan Coe", "Longhaired Redneck", "63", "VG+", "8", "")
),
Array(
Array("David Allan Coe", "Rides Again", "64", "VG+", "6", ""),
Array("David Allan Coe", "Rides Again", "65", "NM", "10", "")
)
),
Array(
Array(
Array("David Bowie", "Hunky Dory", "18", "NM", "40", "Rare!")
),
Array(
Array("David Bowie", "Ziggy Stardust and the Spiders From Mars", "21", "VG++", "15", "")
)
),
Array(
Array(
Array("Earth, Wind & Fire", "Earth, Wind & Fire", "67", "VG+", "10", "")
),
Array(
Array("Earth, Wind & Fire", "That's the Way of the World", "66", "NM", "15", "")
)
),
Array(
Array(
Array("Foghat", "Energized", "68", "NM", "10", ""),
Array("Foghat", "Energized", "2", "M", "2", "")
)
),
Array(
Array(
Array("George Harrison", "All Things Must Pass", "69", "NM", "35", ""),
Array("George Harrison", "All Things Must Pass", "1", "M", "2", "")
)
),
Array(
Array(
Array("Guns N Roses", "Appetite for Destruction", "70", "NM", "20", "")
)
),
Array(
Array(
Array("Hank Williams", "Hank Williams Sings", "29", "M", "55", ""),
Array("Hank Williams", "Hank Williams Sings", "71", "NM", "70", "")
)
),
Array(
Array(
Array("Herbie Hancock", "Empyrean Isles", "72", "VG++", "10", "")
),
Array(
Array("Herbie Hancock", "Head Hunters", "74", "VG++", "13", "")
),
Array(
Array("Herbie Hancock", "Maiden Voyahe", "73", "VG++", "13", "")
)
),
Array(
Array(
Array("Huey Lewis & the News", "Sports", "76", "VG+", "3", ""),
Array("Huey Lewis & the News", "Sports", "77", "VG", "2", ""),
Array("Huey Lewis & the News", "Sports", "75", "NM", "8", "")
)
),
Array(
Array(
Array("Its a Beautiful Day", "Its a Beautiful Day", "20", "VG++", "10", "")
)
),
Array(
Array(
Array("James Brown", "Prisoner of Love", "78", "VG++", "18", "")
)
),
Array(
Array(
Array("Jimi Hendrix", "Are You Experienced", "22", "VG+", "12", "")
)
),
Array(
Array(
Array("John Lee Hooker", "John Lee Hooker Plays and Sings the Blues", "81", "VG++", "15", "")
),
Array(
Array("John Lee Hooker", "Travelin'", "80", "VG++", "15", ""),
Array("John Lee Hooker", "Travelin'", "82", "VG+", "15", ""),
Array("John Lee Hooker", "Travelin'", "79", "VG++", "20", "")
)
),
Array(
Array(
Array("Mazaak", "Fat Man Suicide", "25", "M", "200", "Includes classics like "Cream Green and Beans" and the title track "Fat Man Suicide"!")
)
),
Array(
Array(
Array("Miles Davis", "Bitches Brew", "85", "NM", "30", "")
),
Array(
Array("Miles Davis", "Kind of Blue", "84", "VG+", "15", ""),
Array("Miles Davis", "Kind of Blue", "83", "VG", "10", "")
),
Array(
Array("Miles Davis", "Miles Ahead", "87", "NM", "15", "")
),
Array(
Array("Miles Davis", "Round About Midnight", "86", "NM", "45", "")
),
Array(
Array("Miles Davis", "Star People", "88", "M", "15", "")
)
),
Array(
Array(
Array("Motley Crue", "Theatre of Pain", "4", "VG", "5", ""),
Array("Motley Crue", "Theatre of Pain", "16", "VG", "5", "")
)
),
Array(
Array(
Array("Muddy Waters", "At Newport", "89", "VG+", "10", "")
),
Array(
Array("Muddy Waters", "Hard Again", "90", "VG++", "15", "")
)
),
Array(
Array(
Array("Otis Redding", "In Person at the Whisky a Go Go", "28", "VG++", "20", "")
),
Array(
Array("Otis Redding", "Otis Blue", "92", "VG+", "12", "")
),
Array(
Array("Otis Redding", "The Dock of the Bay", "91", "VG++", "20", "")
)
),
Array(
Array(
Array("Ozzy Osbourne", "Bark at the Moon", "95", "VG++", "15", "")
),
Array(
Array("Ozzy Osbourne", "Blizzard of Ozz", "93", "VG++", "10", ""),
Array("Ozzy Osbourne", "Blizzard of Ozz", "94", "VG++", "12", "")
)
),
Array(
Array(
Array("Parliament", "Mothership Connection", "96", "VG", "8", "")
),
Array(
Array("Parliament", "Motor Booty Affair", "97", "NM", "12", "")
)
),
Array(
Array(
Array("Pink Floyd", "Wish You Were Here", "15", "NM", "17", "")
)
),
Array(
Array(
Array("Sly & the Family Stone", "Stand!", "100", "NM", "20", ""),
Array("Sly & the Family Stone", "Stand!", "98", "VG", "8", ""),
Array("Sly & the Family Stone", "Stand!", "99", "VG++", "15", "")
)
),
Array(
Array(
Array("Taj Mahal", "Giant Step", "6", "VG+", "13", ""),
Array("Taj Mahal", "Giant Step", "19", "VG+", "10", "")
)
),
Array(
Array(
Array("Talking Heads", "Remain in Light", "101", "VG++", "15", ""),
Array("Talking Heads", "Remain in Light", "102", "VG+", "10", ""),
Array("Talking Heads", "Remain in Light", "103", "NM", "20", "")
),
Array(
Array("Talking Heads", "Talking Heads 77", "104", "NM", "25", "")
)
),
Array(
Array(
Array("The Allman Brothers Band", "At Fillmore East", "105", "VG++", "15", ""),
Array("The Allman Brothers Band", "At Fillmore East", "106", "VG++", "15", ""),
Array("The Allman Brothers Band", "At Fillmore East", "11", "NM", "16", "")
),
Array(
Array("The Allman Brothers Band", "Eat a Peach", "8", "G", "3", ""),
Array("The Allman Brothers Band", "Eat a Peach", "9", "VG", "8", ""),
Array("The Allman Brothers Band", "Eat a Peach", "10", "M", "20", "")
)
),
Array(
Array(
Array("The Beatles", "Rubber Soul", "24", "M", "1.93", "")
),
Array(
Array("The Beatles", "Sgt. Pepper's Lonely Hearts Club Band", "5", "VG+", "15", ""),
Array("The Beatles", "Sgt. Pepper's Lonely Hearts Club Band", "27", "VG++", "20", "")
)
),
Array(
Array(
Array("The Mothers of Invention", "Freak Out!", "17", "NM", "20", "")
)
),
Array(
Array(
Array("The Rolling Stones", "Exile on Main Street", "107", "NM", "25", "")
),
Array(
Array("The Rolling Stones", "Let It Bleed", "7", "M", "12", "")
)
),
Array(
Array(
Array("Thelonious Monk", "Brilliant Corners", "108", "VG++", "30", ""),
Array("Thelonious Monk", "Brilliant Corners", "109", "M", "60", "")
),
Array(
Array("Thelonious Monk", "Monk's Dream", "110", "VG++", "19", ""),
Array("Thelonious Monk", "Monk's Dream", "26", "NM", "35", "")
)
),
Array(
Array(
Array("Willie Nelson", "Phases and Stages", "113", "VG++", "12", "")
),
Array(
Array("Willie Nelson", "Red Headed Stranger", "112", "VG++", "11", ""),
Array("Willie Nelson", "Red Headed Stranger", "111", "VG++", "10", "")
)
)
);











var albumNames = Array(Array("Highway to Hell", "Back in Black"), Array("Call Me", "Let's Stay Together"), Array("Singin' the Blues", "Confessin' the Blues", "Sings Spirituals", "Lucille", "Live at the Regal"), Array("Bad Company"), Array("The Freewheelin' Bob Dylan", "The Times They Are A-Changin'", "Another Side of Bob Dylan", "Bringing It All Back Home", "Highway 61 Revisited", "Blonde on Blonde", "John Wesley Harding", "Nashville Skyline", "Self Portrait", "New Morning", "Blood on the Tracks"), Array("Boston"), Array("Jazz at Massey Hall"), Array("Green River", "Cosmos Factory", "Willy and the Poor Boys"), Array("Time Out", "The Dave Brubeck Quartet at Carnegie Hall"), Array("Longhaired Redneck", "Rides Again"), Array("Ziggy Stardust and the Spiders From Mars", "Hunky Dory"), Array("That's the Way of the World", "Earth, Wind & Fire"), Array("Energized"), Array("All Things Must Pass"), Array("Appetite for Destruction"), Array("Hank Williams Sings"), Array("Empyrean Isles", "Maiden Voyahe", "Head Hunters", "Sextant", "Crossings"), Array("Sports", "Picture This"), Array("Its a Beautiful Day"), Array("Prisoner of Love"), Array("Are You Experienced"), Array("Travelin'", "John Lee Hooker Plays and Sings the Blues"), Array("Fat Man Suicide"), Array("Round About Midnight", "Miles Ahead", "Kind of Blue", "Bitches Brew", "Star People"), Array("Theatre of Pain"), Array("At Newport", "Folk Singer", "Brass and the Blues", "Hard Again"), Array("The Dock of the Bay", "Otis Blue", "In Person at the Whisky a Go Go"), Array("Blizzard of Ozz", "Bark at the Moon"), Array("Mothership Connection", "Motor Booty Affair"), Array("Wish You Were Here"), Array("Look What the Cat Dragged In"), Array("The Genius of Ray Charles", "Modern Sounds in Country and Western Music", "The Genius Sings the Blues"), Array("Stand!", "Fresh"), Array("Giant Step", "Taj Mahal", "Happy Just to Be Like I Am", "Music Keeps Me Together"), Array("Remain in Light", "Talking Heads 77", "Speaking in Tongues"), Array("Eat a Peach", "At Fillmore East"), Array("Please Please Me", "A Hard Day's Night", "Help!", "Rubber Soul", "Revolver", "Sgt. Pepper's Lonely Hearts Club Band", "Magical Mystery Tour", "The Beatles (White Album)", "Abbey Road", "Let It Be"), Array("Freak Out!"), Array("Exile on Main Street", "Big Hits (High Tide and Green Grass)", "Let It Bleed"), Array("Brilliant Corners", "Evidence", "Monk's Dream"), Array("Red Headed Stranger", "Yesterday's Wine", "Phases and Stages", "The Sound in Your Mind"));

function byId(id){
return document.getElementById ? document.getElementById(id) : document.all[id];
}
function populateAlbums(index) {
var i = byId('albumSelect').options.length;
for (; i>=0; i--) {
byId('albumSelect').remove(i);
}

var artistAlbums = albumNames[index];
for (i = 0; i < artistAlbums.length; i++) {
var option = document.createElement('option');
option.text = artistAlbums[i];
option.value = artistAlbums[i];
try { byId('albumSelect').add(option, null); } // non-IE
catch(e) { byId('albumSelect').add(option); } // IE
}
}
</script>

最佳答案

您的字符串之一包含双引号:

Array("Mazaak", "Fat Man Suicide", "25", "M", "200", "Includes classics like "Cream Green and Beans" and the title track "Fat Man Suicide"!")

你可以用黑斜杠来逃避它们

Array("Mazaak", "Fat Man Suicide", "25", "M", "200", "Includes classics like \"Cream Green and Beans\" and the title track \"Fat Man Suicide\"!")

或在字符串周围使用单引号

Array("Mazaak", "Fat Man Suicide", "25", "M", "200", 'Includes classics like "Cream Green and Beans" and the title track "Fat Man Suicide"!')

关于JavaScript 数组短路脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5135414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com