F
Fred
I'd like to return a match and its index number in one of two arrays that
matches the filename within:
var menuURLs = new Array
("dinner.html",
"lunch.html",
"drinks.html");
var headerURLs = new Array
("partyservice.html",
"deliveries.html",
"reservation.html");
The following code cycles through the menuURLs array and compares it with
"file" (the filename of the html page):
var i = menuURLs.length;
while (i-- && menuURLs !=file){}
var currentIndex = (i<0)? 0 : i;
This works fine and returns the current index of the array if a match is
found. If the filename does not match any current page name, it still
returns "0" however. Instead, and what I would like is that the search
continues into the next array in case it fails to find a match in the first:
var i = headerURLs.length;
while (i-- && headerURLs !=file){}
var currentIndex = (i<0)? 0 : i;
In either cases I'd like to return an index number as well the array name
in which it was found, but only if a match returns, otherwise it should
return false. There will never exist a same filename string in both arrays.
Anyone has any idea how to most easily do this?
matches the filename within:
var menuURLs = new Array
("dinner.html",
"lunch.html",
"drinks.html");
var headerURLs = new Array
("partyservice.html",
"deliveries.html",
"reservation.html");
The following code cycles through the menuURLs array and compares it with
"file" (the filename of the html page):
var i = menuURLs.length;
while (i-- && menuURLs !=file){}
var currentIndex = (i<0)? 0 : i;
This works fine and returns the current index of the array if a match is
found. If the filename does not match any current page name, it still
returns "0" however. Instead, and what I would like is that the search
continues into the next array in case it fails to find a match in the first:
var i = headerURLs.length;
while (i-- && headerURLs !=file){}
var currentIndex = (i<0)? 0 : i;
In either cases I'd like to return an index number as well the array name
in which it was found, but only if a match returns, otherwise it should
return false. There will never exist a same filename string in both arrays.
Anyone has any idea how to most easily do this?