I have a <div> element which contains a chain of auto-popullating dropdown boxes that grows horizontally towards the right as more boxes are created. When enough are created, I have a scrollbar that forms so the boxes don’t go of the page.
As the scrollbar appears, I would like it to default on the right side instead of the left side, that way members don’t have to keep manually moving the scrollbar in order to see the next box.
This seems to work initially when it loads, but when I start selecting sub-categories and the “tree” grows longer, the scrollbar does not move to the right side.
When I select a sub-category, there is an AJAX script that opens up sub-category2.php, which displays the next box list of sub-categories (then sub-category3.php opens the next and so on). This whole “tree” is inside of <div class=“main”></div>
I tried to add the above code in the individual sub-category2.php, sub-category3.php files as well but the <div> scrollbar does not move to the right when the tree grows.
Awesome! I’ve just added that code in there like this:
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(“ShowSubcategory2”).innerHTML=xmlhttp.responseText;
$(“div.demo”).scrollLeft(document.body.clientWidth);
}
}
This seems to be working great. I was fiddling around with that area of the ajax earlier but never placed this code in there. Thanks a lot Paul for the hints and guiding me through the process.