creating Array in External HTML Object

Prajkta:I just finished a project using this type of object to carry the array from one page to the next. If you're using the titlemanager then understand that this frameset object (TitleMgr) is open all of the time so that if variables are written to it then they are available to all html pages while the browser session is open.Figure out a name for your array (ie failedArray) then initialize it on the first page of your course.function initMyArray(){titleMgr = getTitleMgrHandle();if( titleMgr ){titleMgr.failedArray = new Array();}}Now you can push items onto the array but you can't seem to remove them (splice, etc) - some security issue?) UNLESS you create a second array (temporary array) that you initialize with each page (or as needed) and populate by iterating thru the Title Manager Array and adding each item to the temporary array, basically making a duplicate of the Title Manager Array.var tempArray = new Array();function rewriteTheTempArray(){for (var j = 0;j < titleMgr.failedArray.length; j++){tempArray[j] = titleMgr.failedArray[j];}}Now you have an array that wasn't created dynamically that you can manipulate ANY way you want to - JUST REMEMBER - before you leave the page, REWRITE THE Title Manager Array with the new items; The first line of the function WIPES OUT the original Title Manager Array.function rewriteTheTitleMgrArray()titleMgr.failedArray = new Array();for (var j = 0;j < tempArray.length; j++){titleMgr.failedArray[j] = tempArray[j];}}A handy little function I use to report whether an item is inside an array AND to report its position in case I want to remove or replace it is:Array.prototype.inArray = function (value){var j;for (j=0; j < this.length; j++){if (this[j] === value){posInArray = j;return true;}}return false;}You will need to declare the posInArray var before this function is used.Hope this helps - -PeterEdited By: Lex_Tensions on 2007-10-24 15:12:10

Discussions have been disabled for this post