loading divs dynamically -- how to detect which one loaded currently..

M

maya

I'm using a function like this to load divs dynamically (and hide
current one..)

function get_img(curr_img,curr_nav,new_img,new_nav2) {
var img_top = eval('document.getElementById(' + "curr_img" + ')');
var img_new = eval('document.getElementById(' + "new_img" + ')');
var nav_top = eval('document.getElementById(' + "curr_nav" + ')');
var nav_new = eval('document.getElementById(' + "new_nav" + ')');
img_top.style.visibility = "hidden";
img_new.style.visibility = "visible";
nav_top.style.visibility = "hidden";
nav_new.style.visibility = "visible";
curr_img = new_img;
curr_nav = new_nav;
}

problem I always run into in situations like this is I can't tell which
one is currently loaded.. how do you detect which div is currently loaded?

this is in JSP, divs generated with loops...

for (int i = 0; i < photos.length; i++) {
%>
<div id="nav<%=photos%>">

etc...

thank you.............
 
T

TheBagbournes

maya said:
I'm using a function like this to load divs dynamically (and hide
current one..)

function get_img(curr_img,curr_nav,new_img,new_nav2) {
var img_top = eval('document.getElementById(' + "curr_img" + ')');

Why are you evaluating instead of just doing

var img_top = document.getElementById(cur_img);

??????????
var img_new = eval('document.getElementById(' + "new_img" + ')');
var nav_top = eval('document.getElementById(' + "curr_nav" + ')');
var nav_new = eval('document.getElementById(' + "new_nav" + ')');
img_top.style.visibility = "hidden";
img_new.style.visibility = "visible";
nav_top.style.visibility = "hidden";
nav_new.style.visibility = "visible";
curr_img = new_img;
curr_nav = new_nav;
}

problem I always run into in situations like this is I can't tell which
one is currently loaded.. how do you detect which div is currently loaded?


Not enough information here to have any clue what you mean.

this is in JSP, divs generated with loops...

for (int i = 0; i < photos.length; i++) {
%>
<div id="nav<%=photos%>">

etc...

thank you.............
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top