I am using a "for loop" to call getjson multiple times and receive a response to display items on sale inside a div. Currently, my code displays the item name to the right of each frame, but I want the item name to appear below the iframe, similar to the code block below:
Sample div item that I want to output instead of my current code output, but I'm not sure how::
<li>
<iframe src='http://bsite.com/itemshow.php?pen' height=200 width=200 style='border: none;'></iframe><br>
<div class="details">
<div class="title">
<a href="/pen/">pen</a>
</div>
</div>
</li>
Could you please help me with adding the item name below each div item (similar to the code block above) and restricting the number of divs to 5 per row?
Part of the code that currently displays the div:
var siteContents2 = "<iframe src='http://bsite.com/itemshow.php?"+itemName' height=200 width=200 style='border: none;'></iframe>"+itemName;
document.getElementById("myDiv").innerHTML += siteContents2;
Full code:
function GetJSONResult(itemName)
{
$.getJSON('http://anyorigin.com/get?url=http://asite.com/checkit.php'+ itemName + '/&callback=?', function(data){
var siteContents = data.contents;
//writes to textarea
document.myform.outputtext.value = siteContents ;
var n=siteContents.search("This item is not on sale");
if(n===-1)
{
//alert("This item is on sale. n:"+n);
var siteContents2 = "<iframe src='http://bsite.com/itemshow.php?"+itemName' height=200 width=200 style='border: none;'></iframe>"+itemName;
document.getElementById("myDiv").innerHTML += siteContents2;
};
});
};
items=["pen","book","paper","ink","tshirt","map"];
for (var i=0;i<items.length;i++)
{
//document.write(i+")"+items[i] + "<br>");
GetJSONResult(items[i]);
}
</script>
</head>
<body>
<div id="myDiv"></div>