<html>
<head><title>test</title></head>
<body>
<table id="tab_inv" width="100%">
</table>
<input type="button" value="run" onclick="viewtab()">
<script type="text/javascript">
ItemArr = {
Type1: {
item1: {
id: 'item1-1',
img: 'img/items/item1-1.png'
},
item2: {
id: 'item1-2',
img: 'img/items/item1-2.png'
},
item3: {
id: 'item1-3',
img: 'img/items/item1-3.png'
},
item4: {
id: 'item1-4',
img: 'img/items/item1-4.png'
}
},
Type2: {
item1: {
id: 'item2-1',
img: 'img/items/item2-1.png'
}
}
};
function viewtab() {
var table=document.getElementById('tab_inv');
while (table.firstChild)
table.removeChild(table.firstChild);
var tr
k=0;
for (var key0 in ItemArr) {
for (var key1 in ItemArr[key0]) {
if (parseInt(k/4)==k/4) {
tr=document.createElement('TR')
table.appendChild(tr)
}
var td=document.createElement('TD')
var img=document.createElement('IMG')
// td.innerHTML='<img src="'+ItemArr[key0][key1].img+'" id="'+ItemArr[key0][key1].id+'" onmouseover="showpopup(this)">'
img.src=ItemArr[key0][key1].img;
img.id=ItemArr[key0][key1].id;
table.appendChild(tr)
tr.appendChild(td)
td.appendChild(img)
k++
}
}
var ek=((k/4)-parseInt(k/4))/0.25;
if (ek!=0) {
for (var i=0;i<(4-ek);i++) {
var td=document.createElement('TD')
td.innerHTML='<img src="img/slot_empty.png">'
tr.appendChild(td)
}
}
}
</script>
</body>
</html>