Search code examples
javascripthtmlcoldfusioncoldfusion-9

Using miltiple divs refresh in slide show


I am using the code below to refresh multiple divs in another form but this works only for the same div multiple times. Please check the code if my explanation is not correct.

<script type="text/javascript"> 
window.setInterval(function(){$('#div4,#div1').load('exp1.cfm')}, 1000);
</script> 

I am using a slider to slide the graphs. I kept the divs in the form called newslider1.cfm and included in the main form slider.cfm. So its working, but I need to update the data within the divs every 2 seconds without disturbing the slides on the main page. However, using this code I can only refresh one div at a time and not more than that. Here is the code I am using for this:

main page code:

<div class="container"> 
    <div id="slides">
        <cfinclude template="newslider1.cfm">
    </div>
</div>

scripts: I have used this previously but it is working for only one div:

window.setInterval(function()$('#div1,#div2,#div3').load('newslider1.cfm');},1000);

now: I have tried this but it is working for only one div

<script type="text/java script">    
var Count = 0;
window.setInterval(function(){change()}, 2000);

function change()
{       
    if (Count >= 4)
    {
        Count = 0;
    }
    else
    {
        Count = Count + 1;
        var newdiv = "div" + Count; 
        $("#"+newdiv).load("newslider1.cfm");
    }
}
</script> 

child page code:

<div id="div1">content 1 here</div>
<div id="div2">content 2 here</div>
<div id="div3">content 3 here</div>

Solution

  • This is the script working fine ,Insted of the previous one.
         <script type="text/javascript">    
         window.setInterval(function(){
        $('#div1').load('UpdatingSlider.cfm #div1');
        $('#div2').load('UpdatingSlider.cfm #div2');
        $('#div3').load('UpdatingSlider.cfm#div3')},2000);
    
        </script>