If $("id") returns null (like in this instance) then the id does not exist on the page
This might be handled better using a class on each of the panels and simply holding which is the open/minimized index that way you don't have to worry about what ids exist Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com On Mon, Oct 15, 2012 at 11:15 AM, Peter Sysko <petersy...@gmail.com> wrote: > I love prototype and scriptacualous. I don't combine with jquery so i know > i am not having a noclonflict headache, > and I am just trying to get the visible() function ( > http://prototypejs.org/api/element/visible) > to not throw null type error exceptions: here is the function I need to > fix, syntactically: > the function creates an associative array to track which of 33 system > panels are either open, unopen, or minimized*: > **(the systems are indexed from 100 to 132)*>> > > function get_system_states() { > var k=0; var sys_array = new Array(); var open_div=''; var min_div=''; > for(k=100;k<132;k++){ > open_div = 'system'+k+''; > min_div = open_div+'_minimized'; > if ($(open_div).visible()==true) { > sys_array[k] = "o"; // o = open > } > if ($(min_div).visible()==true) { > sys_array[k] = "m"; // m = minimized > } > if (($(open_div).visible()==false)&&($(min_div).visible()==false)) > { > sys_array[k] = "c"; // u = unopen > } > } > return sys_array; > } > > Javscript console error says : > > 1. Uncaught TypeError: Cannot call method 'visible' of null > 1. > > > the first IF statement in the for loop is throwing the exception, but I > assume I am not assigning the div values correctly? > i have found no answers in this group from a text search and from a > general google search. > is this a single quotation reference? my div id's are dynamically written > in php codeignite, which shouldnt really matter. > > any suggestions for how to properly get the visibility of each div in each > current state? > thanks!! > -pete > > -- > You received this message because you are subscribed to the Google Groups > "Prototype & script.aculo.us" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/prototype-scriptaculous/-/s8MPSAK2FwMJ. > To post to this group, send email to > prototype-scriptaculous@googlegroups.com. > To unsubscribe from this group, send email to > prototype-scriptaculous+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/prototype-scriptaculous?hl=en. > -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.