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

Discussion in 'Javascript' started by maya, Jan 25, 2007.

  1. maya

    maya Guest

    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%>">


    thank you.............
    maya, Jan 25, 2007
    1. Advertisements

  2. Why are you evaluating instead of just doing

    var img_top = document.getElementById(cur_img);


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

    TheBagbournes, Jan 27, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.