Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > loading divs dynamically -- how to detect which one loaded currently..

Reply
Thread Tools

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

 
 
maya
Guest
Posts: n/a
 
      01-25-2007
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.............

 
Reply With Quote
 
 
 
 
TheBagbournes
Guest
Posts: n/a
 
      01-27-2007
maya wrote:
> 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[i]%>">
>
> etc...
>
> thank you.............
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
swapping divs -- when divs NOT positioned absolutely.. maya Javascript 4 11-16-2007 05:11 PM
Dynamically Loaded controls loading other controls =?Utf-8?B?V291dGVy?= ASP .Net 3 02-27-2006 07:25 PM
Need to detect page state - loading - loaded - etc ??? Alex Javascript 1 02-24-2006 05:51 PM
Managing divs within divs.... rich HTML 0 02-02-2006 07:38 PM



Advertisments