This is a SCHOOL PROJECT and not something being used on a functioning website, so no worries that it's client side only! We've been asked to expand upon our last assignment to create a script that would allow out teacher to input an ARTIST name in the search box on our "music store" homepage, which would then search the JavaScript array that we built and then return the results in a new window with the "Album Name", as well as a link to another page for additional information (not so much worried about that link just yet, trying to get the actual search & album return functionality working first!).
Below is what I have, and the JS FIddle is: http://jsfiddle.net/2AS53/. Any assistance or ideas on what's wrong would be greatly appreciated. Thanks for your help...
<div class="form">
<form method="get" action="input">
<input name="textfield" type="text" class="colortext" placeholder=" Search entire store..." />
</form>
Search
< script >
var myInventory = [{
id: 001,
title: "Total Life Forever",
artist: "FOALS",
price: 14.99,
released: "March, 2009",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 002,
title: "Bein Love",
artist: "Locksley",
price: 14.99,
released: "April, 2012",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 003,
title: "Privileged",
artist: "Nick Moss",
price: 14.99,
released: "June, 2011",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 004,
title: "Asondeguerra",
artist: "Juan Louis Guerra",
price: 14.99,
released: "September, 2013",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 017,
title: "Way Out Here",
artist: "Josh Thompson",
price: 14.99,
released: "August, 2010",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 018,
title: "Tremolo",
artist: "The Pines",
price: 14.99,
released: "January, 2007",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 019,
title: "Live From Freedom Hall",
artist: "Lynyrd Skynyrd",
price: 14.99,
released: "June, 2010",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 020,
title: "Achin & Shakin",
artist: "Laura Bell Bundy",
price: 14.99,
released: "July, 2013",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 021,
title: "Here I Am",
artist: "Marvin Sapp",
price: 14.99,
released: "November, 2011",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 022,
title: "Just James",
artist: "J Moss",
price: 14.99,
released: "March, 2011",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, {
id: 013,
title: "Tom Petty - Live",
artist: "Tom Petty",
price: 14.99,
released: "May, 2010",
tracks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
quantity: 1
}, ];
search.onclick = myInventory() {
var formInput = document.getElementById("formInput").value;
for (i = 0; i < data.length; i++) {
if (data[i] == formInput) {
onclick = "java script: openWin('search.html') {"Album Name:"' title};
} else {
onclick = "java script: openWin('search.html') ("No Artists Found");
}
}
}; </script>