Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old January 25th, 2007, 08:05 PM
maya
Guest
 
Posts: n/a
Default loading divs dynamically -- how to detect which one loaded currently..

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[i]%>">

etc...

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


  #2  
Old January 27th, 2007, 12:15 PM
TheBagbournes
Guest
 
Posts: n/a
Default Re: loading divs dynamically -- how to detect which one loaded currently..

maya wrote:
Quote:
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);

??????????
Quote:
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.

Quote:
this is in JSP, divs generated with loops...
>
for (int i = 0; i < photos.length; i++) {
%>
<div id="nav<%=photos[i]%>">
>
etc...
>
thank you.............
>
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.