#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    162
    Rep Power
    21

    Problem with output the data


    Hi guys,

    I have got a problem with my current script and I really need your help. I have four blocks on my webpage, I am trying to scrape the title4" data from my other script to output it in my main page. I can be able to output three titles without have any problem, but I can't be able to output on four titles only three .

    Here is the code:

    javascript Code:
    function getSchule($link,j)
    {
      //var widthval = 350;
      var widthval =  850;
      var parts = $link.split("/");
      var links = parts[parts.length-1];
      var programlength = 0;
     
      $.ajax({
      url:$.trim(links),
      type:'GET',
      data:'',
      success: function(data)
      {
        var $data = $(data);		
        var title1 = $data.filter("#title1").html();
        var title2 = $data.filter("#title2").html();
        var title3 = $data.filter("#title3").html();
        var title4 = $data.filter("#title4").html();
     
        var time1 = $data.filter("#time1").html();
        var time2 = $data.filter("#time2").html();
        var time3 = $data.filter("#time3").html();
        var time4 = $data.filter("#time4").html();
        var time5 = $data.filter("#time5").html();
     
        time1 = time1.split(" ");
        var time1AMPM = time1[1];
        time1 = time1[0].split(":");
        time1= time1[0]+'.'+time1[1];
        if($.trim(time1AMPM) == 'PM' && time1<12)
    	time1 = parseFloat(time1)+12;
     
    	time2 = time2.split(" ");
    	var time2AMPM = time2[1];
    	time2 = time2[0].split(":");
    	time2= time2[0]+'.'+time2[1];
        if($.trim(time2AMPM) == 'PM' && time2<12)
    	time2 = parseFloat(time2)+12;
     
    	time3 = time3.split(" ");
    	var time3AMPM = time3[1];
    	time3 = time3[0].split(":");
    	time3= time3[0]+'.'+time3[1];
        if($.trim(time3AMPM) == 'PM' && time3<12)
    	time3 = parseFloat(time3)+12;
     
    	time4 = time4.split(" ");
    	var time4AMPM = time4[1];
    	time4 = time4[0].split(":");
    	time4= time4[0]+'.'+time4[1];
        if($.trim(time4AMPM) == 'PM' && time4<12)
    	time4 = parseFloat(time4)+12;
     
    	time5 = time5.split(" ");
    	var time5AMPM = time5[1];
    	time5 = time5[0].split(":");
    	time5= time5[0]+'.'+time5[1];
        if($.trim(time5AMPM) == 'PM' && time5<12)
    	time5 = parseFloat(time5)+12;
     
    	var difftime2time1 = (parseFloat(time2) - parseFloat(time1)).toFixed(2);
    	var difftime3time2 = (parseFloat(time3) - parseFloat(time2)).toFixed(2);
    	var difftime4time3 = (parseFloat(time4) - parseFloat(time3)).toFixed(2);
    	var difftime5time4 = (parseFloat(time5) - parseFloat(time4)).toFixed(2);
     
    	if(isNaN(difftime2time1))
    	{
    	  difftime2time1=0;
    	}
    	if(isNaN(difftime3time2))
    	{
    	  difftime3time2=0;
    			}
    	if(isNaN(difftime4time3))
    	{
    	  difftime4time3=0;
    	}
    	if(isNaN(difftime5time4))
    	{
    	  difftime5time4=0;
    	}	
    	var currenttotal = 0;	
    	var firstele = ((j-1)*4)+1; // how many programme i want to output in per block
    	var lastele = parseInt(firstele)+2;
    	var k=1;
    	var programlength = 0;
    	for(;firstele <= lastele;firstele++)
    	{
    	  var nexttimedate = parseInt(k)+1;
    	  programlength = parseFloat(programlength) + parseFloat(eval('difftime'+nexttimedate+'time'+k));
     
    	  if((eval('difftime'+nexttimedate+'time'+k)) > 0.99 && (eval('difftime'+nexttimedate+'time'+k)) <=1.00 )
    	  {
    	    $('#programe'+firstele).addClass("span1hr");
    	    width[j]=517;
    	  }
     
    	  if((eval('difftime'+nexttimedate+'time'+k)) > 1.00 && (eval('difftime'+nexttimedate+'time'+k)) <=1.30 )
    	  {
    	    $('#programe'+firstele).addClass("span1hr");
    	    width[j]=517;  
    	  }
     
    	  if((eval('difftime'+nexttimedate+'time'+k)) > 1.03 && (eval('difftime'+nexttimedate+'time'+k)) <=1.33 )
    	  {
    	    $('#programe'+firstele).addClass("span1hr");
    	    width[j]=517;  
    	  }
     
    	  if((eval('difftime'+nexttimedate+'time'+k)) > 1.30 && (eval('difftime'+nexttimedate+'time'+k)) <=2.00 )
    	  {
    	    $('#programe'+firstele).addClass("span1_5hr");
    	    width[j]=701;  
    	  }
     
    	  if((eval('difftime'+nexttimedate+'time'+k)) > 2.00 && (eval('difftime'+nexttimedate+'time'+k)) <=2.30 )
    	  {
    	    $('#programe'+firstele).addClass("span2hr");
    	    width[j]=1303;
    	  }
     
    	  if((eval('difftime'+nexttimedate+'time'+k)) > 2.30 && (eval('difftime'+nexttimedate+'time'+k)) <=3.00 )
    	  {
    	    $('#programe'+firstele).addClass("span2_5hr");
    	    width[j]=1553;
    	  }
     
    	  if((eval('difftime'+nexttimedate+'time'+k)) > 3.00 && (eval('difftime'+nexttimedate+'time'+k)) <=3.30 )
    	  {
    	    $('#programe'+firstele).addClass("span3hr");
    	    width[j]=1803;
    	  }
     
     
    	  if(programlength == 0.30)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span0hr");
    	      width[j]=250;
    	    }
    	  }
     
    	  if(programlength == 1.00)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span1hr");
    	      width[j]=517;
    	    }    
    	  }
     
    	  if(programlength == 1.01)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span1hr");
    	      width[j]=517;
    	    }    
    	  }
     
    	  if(programlength == 1.02)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span1hr");
    	      width[j]=517;
    	    }    
    	  }
     
    	  if(programlength == 1.03)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span1hr");
    	      width[j]=517;
    	    }    
    	  }
     
    	  if(programlength == 1.30)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span1_5hr");
    	      width[j]=701;
    	    }	    
    	  }
     
              if(programlength == 2.00)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span2hr");
    	      width[j]=1303;
    	    }	        
    	  }
     
    	  if(programlength == 2.30)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span2_5hr");
    	      width[j]=1553;
    	    }	    
    	  }
     
    	  if(programlength == 3.00)
    	  {
    	    if(currenttotal == 0)
    	    {
    	      $('#programe'+firstele).addClass("span3hr");
    	      width[j]=1803;
    	    }	    
    	  }
    	  currenttotal++;
    	  pgmcontent[firstele] = eval('title'+k);
    	  k++;		
    	}
    	checksum+=j;
     
    	if(checksuminit == checksum)
    	{
     
    	  for(var ii=1;ii<width.length-1;ii++)
    	  {
    	    widthval+=width[ii];
    	  }
     
    	  for(var jj=1;jj <= pgmcontent.length-1;jj++)
    	  {
    	    $('#programe'+jj).html(pgmcontent[jj]);
    	  }
     
    	  for(var kk=1;kk <= imagecontent.length-1;kk++)
    	  {
    	    $('#image'+kk).html(imagecontent[kk]);
    	  }
    	    $("body").find('.rowSubPgm').each(function(index) {
    	    $(this).css( "width", widthval+"px");
    	  });
    	  $("div").show();	
    	}
      }   
      });
    }



    I am using ajax to output the data to my main page. I can't be able to figure out where the trouble is coming from.

    Does anyone know what the problem is?

    Any idea??
    Last edited by requinix; June 7th, 2013 at 12:16 PM. Reason: that is not php code

IMN logo majestic logo threadwatch logo seochat tools logo