javascript - How do I empty global arrays used in a pop up slideshow? -


i've created program can choose set of images checking checkboxes. image url's , alt-texts stored in 2 arrays. when clicking av button on html-page open new window calls on arrays window.opener.

when closing new window empty arrays. otherwise pictures chosen in first round displayed in slideshow when opening second time. understand can empty arrays method: array.length= 0;

but add code? i'm quite lost. i'm pasting code, perhaps can give me hand.

var imgurllist = [], imgtextlist = [], //these arrays need emptied     windvar = null;  function init() {     var tags, i, openwindow;      tags = document.getelementsbyclassname("unmarkedimg");     openwindow = document.getelementbyid("slideshowbtn");     openwindow.onclick = savepicsforslideshow;     (i = 0; < tags.length; i++) {         tags[i].parentnode.onmouseover = showlargepict;         tags[i].parentnode.onmouseout = hidelargepict;     } }  window.onload = init;  function showlargepict() {     var largepicttagdiv = this.getelementsbyclassname("innerbox")[0];     var largepicttagparentdiv = largepicttagdiv.parentnode;     var imgtag = largepicttagparentdiv.getelementsbytagname('img')[0];     var checkboxlargepict = largepicttagdiv.getelementsbytagname('input')[0];      if (checkboxlargepict.checked)         imgtag.classname = "markedimg";     else imgtag.classname = "unmarkedimg";      largepicttagdiv.style.visibility = "visible"; } // end showlargepict  function hidelargepict() {     var largepicttag;     largepicttag = this.getelementsbyclassname("innerbox")[0];     largepicttag.style.visibility = "hidden"; }   function savepicsforslideshow() {     var innerboxes = document.getelementsbyclassname("innerbox");      (i = 0; < innerboxes.length; i++) {         checkboxlargepict = innerboxes[i].getelementsbytagname('input')[0];         if (checkboxlargepict.checked) {             var imgtagsrc = innerboxes[i].getelementsbytagname('img')[0].src;             imgurllist.push(imgtagsrc);             var spantagtext = innerboxes[i].getelementsbytagname('span')[0].innerhtml;             imgtextlist.push(spantagtext);         }     }      if (imgtextlist.length > 0) {         newwindow(500, 600, "slideshow.htm");     }  }  function newwindow(width, height, filename) {     var windowproperties;     windowproperties = "top=100,left=100,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height;     if (windvar != null) if (windvar.closed == false) windvar.close();     windvar = window.open(filename, "", windowproperties); } 

please excuse programming , english grammar shortcomings. i'm new javascript. //henrik, göteborg, sweden.

at beginning of savepicsforslideshow function, empty out each array.

imgurllist.length = 0; imgtextlist.length = 0; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -