김지완

water web base

This diff is collapsed. Click to expand it.
......@@ -17,34 +17,34 @@
<script>
$(document).ready(function(){
$.getJSON('ex1.json', function(data){
$.getJSON('water.json', function(data){
var html = [];
$.each(data, function(i, item){
console.log(item.users.length);
console.log(item.product.length);
html.push('<div class="container">')
var cnt = 0;
var name = "";
for(var num = 0; num < item.users.length; num++){
for(var num = 0; num < item.product.length; num++){
if(name != item.users[num].name){
if(name != item.product[num].name){
if(num!=0){html.push('</div>')} // close col
if(num!=0){if(cnt%3==0){html.push('</div>');}} // close row
if(cnt%3==0){html.push('<div class="row">');} // open row
cnt = cnt + 1;
html.push('<div class="col-sm">');
html.push('<div><img src="'+item.users[num].img+'" target="_blank" width="200" height="200"></div>');
html.push('<div> 상품명 : '+item.users[num].name+'</div>');
html.push('<div> mart : '+item.users[num].mart+'</div>');
html.push('<div> 가격(100ml당가격) : '+item.users[num].price+'('+item.users[num].unit+')'+'</div>');
html.push('<div><img src="'+item.product[num].img+'" target="_blank" width="200" height="200"></div>');
html.push('<div> 상품명 : '+item.product[num].name+'</div>');
html.push('<div> mart : '+item.product[num].mart+'</div>');
html.push('<div> 가격(100ml당가격) : '+item.product[num].price+'('+item.product[num].unit+')'+'</div>');
}
else{
html.push('<div> mart : '+item.users[num].mart+'</div>');
html.push('<div> 가격(100ml당가격) : '+item.users[num].price+'('+item.users[num].unit+')'+'</div>');
html.push('<div> mart : '+item.product[num].mart+'</div>');
html.push('<div> 가격(100ml당가격) : '+item.product[num].price+'('+item.product[num].unit+')'+'</div>');
}
name = item.users[num].name;
name = item.product[num].name;
}
html.push('</div>'); // close col
......
This diff is collapsed. Click to expand it.