Click here to Skip to main content
14,923,038 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
JavaScript
function makeTable(data)
{

 var tr1 = "";
 tr1 = $('<td />');
 var tr2 = "";
 tr2 = $('<td />');
 var tr3 = "";
 tr3 = $('<td />');
 var tr4 = "";
 tr4 = $('<td />');
 //count=data.length;
 for (var i = 1;  i < data.length; i++) {
	// var d=data[i];
	 if(i<=9)
	{
			$('#disp').html(firstPageFunction(data));
	}
	
	else if(i>9 && i<=18)
	 {
		// for(var j = 9; j<data.length;>	//	{
			$('#disp2').html(secPageFunction(data));
		
		//}//for j
	}
	else if(i>18 && i<=27)
	{
		$('#disp3').html(thirdPageFunction(data));
		
	}
	
	else if(i>27 && i<=36)
	{
		$('#disp4').html(fourthPageFunction(data));
		
	}
	else 
	{
		break;
		//continue;
	}
	
 }//for i
 


 
function firstPageFunction(data)
{
	//var temp=0;
	tr1.append("<td align="char"><a href="<?php echo $_SERVER[" php_self="] ?>?<?php echo md5(" c=") ?>="+data[i].cat_id+"&<?php echo md5(" p=") ?>="+data[i].pd_id+""><img src=images/product/"+ data[i].pd_image +" ></a> <br><font size="2" color="#446664">"+data[i].pd_name+"</font></br> 																												<br><font size="2" color="#446664">"+data[i].pd_price+"</font></br><br><br><span class="\"price\""><font size="2">Price : "+data[i].pd_price+"</font></span> </br></br></td>");
	//temp+1;
	if(i%3==0)
	{
		tr1.append("");
		tr1.append("<tr><td></td></tr>");
		//temp=0;
	}
	return tr1;
	
		
}//tableFunction 

function secPageFunction(data)
{
	//var temp=0;
	tr2.append("<td align="char"><a href="<?php echo $_SERVER[" php_self="] ?>?<?php echo md5(" c=") ?>="+data[i].cat_id+"&<?php echo md5(" p=") ?>="+data[i].pd_id+""><img src=images/product/"+ data[i].pd_image +" ></a> <br><font size="2" color="#446664">"+data[i].pd_name+"</font></br> 																												<br><font size="2" color="#446664">"+data[i].pd_price+"</font></br><br><br><span class="\"price\""><font size="2">Price : "+data[i].pd_price+"</font></span> </br></br></td>");
	//temp+1;
	if(i%3==0)
	{
		tr2.append("");
		tr2.append("<tr><td></td></tr>");
		//temp=0;
	}
	return tr2;
	
}//sectTablefunction 
function thirdPageFunction(data)
{
	//var temp=0;
	tr3.append("<td align="char"><a href="<?php echo $_SERVER[" php_self="] ?>?<?php echo md5(" c=") ?>="+data[i].cat_id+"&<?php echo md5(" p=") ?>="+data[i].pd_id+""><img src=images/product/"+ data[i].pd_image +" ></a> <br><font size="2" color="#446664">"+data[i].pd_name+"</font></br> 																												<br><font size="2" color="#446664">"+data[i].pd_price+"</font></br><br><br><span class="\"price\""><font size="2">Price : "+data[i].pd_price+"</font></span> </br></br></td>");
	//temp+1;
	if(i%3==0)
	{
		tr3.append("");
		tr3.append("<tr><td></td></tr>");
		//temp=0;
	}
	return tr3;
	
}
function fourthPageFunction(data)
{
	//var temp=0;
	tr4.append("<td align="char"><a href="<?php echo $_SERVER[" php_self="] ?>?<?php echo md5(" c=") ?>="+data[i].cat_id+"&<?php echo md5(" p=") ?>="+data[i].pd_id+""><img src=images/product/"+ data[i].pd_image +" ></a> <br><font size="2" color="#446664">"+data[i].pd_name+"</font></br> 																												<br><font size="2" color="#446664">"+data[i].pd_price+"</font></br><br><br><span class="\"price\""><font size="2">Price : "+data[i].pd_price+"</font></span> </br></br></td>");
	//temp+1;
	if(i%3==0)
	{
		tr4.append("");
		tr4.append("<tr><td></td></tr>");
		//temp=0;
	}
	return tr4;
	
}


 
}//end make table
Posted
Updated 30-Aug-15 21:11pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900