View Single Post
Old 03-13-2008, 03:11 PM   #29 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
i started re writing my script. having javascript cache the returns from the sql table to reduce strain on the server from having to search the table every time the user types a new character. i wrote this function to search a multi dimensional array, for a string. return an md array containing all the matches, or return -1 if no matches are found.(i picked -1 because this function is meant to sorta mimic .indexOf)

Code:
function searcharray(searchkey, searcharray) { var indices = []; var luck = false; for(var i = 0; i < searcharray.length; i++) { for(var i2 = 0; i2 < searcharray[i].length; i2++) { if(searchkey == searcharry[i][i2].substr(0, searchkey.length)) { document.write('what the ?!'); luck = true; indices.push(searcharray[i]); } } } if(luck == false) { document.write('this just is true'); indices = -1; document.write(indices); } document.write(luck); return indices; }
every time i run the script, neither of the document.writes executes. i must have a simple error staring me in the face somewhere. any help?
__________________
falsepride is offline   Reply With Quote