0
我將我的數組填充到checklistRequest.js中,我想在包含js代碼的Termine_1s.html文件中訪問它。我可以訪問它,但是當我想遍歷它時,它只給出了單個數字而不是字符串。在另一個js文件中訪問js數組
我該如何解決這個問題?
checklistRequest.js
//Calls the checkbox values
function alertFunction()
{
//Retrieve the object from storage
var retrievedObject = localStorage.getItem('checkboxArray');
console.log('retrievedObject: ', JSON.parse(retrievedObject));
return retrievedObject;
}
Termine_1s.html
//Checks if title was checked already
var checklistRequest = alertFunction();
var titleAccepted = true;
for (var a = 0; a < checklistRequest.length; a++)//Iterates through whole array
{
if(title != checklistRequest[i] && titleAccepted == true)//Stops if false
{
titleAccepted = true;
}
else
{
titleAccepted = false;
}
}
謝謝,解決了它。 :) – Fuby