aspx feed to display business profiles by business type
Hello everyone,
My site displays business profiles from an aspx feed. The feed currently only lists profiles alphabetically.
I'm trying to display them within their category (Farms, Artists...).
This is the current alphabetical script running on the site:
<script type="text/javascript" src="http://www.managemymarket.com/js/jquery-1.3.2.min.js"></script>
<div id="dOX"></div>
<script type="text/javascript">
var arrVendors;
function ox(arr) {
arrVendors = arr;
var html = '';
for (var i = 0; i < arrVendors.length; i++) {
var v = arrVendors[i];
html += '<p><div class=\"vendor\"><a style=\"float:left\" href=\"\" index=\"' + i + '\">' + v.company + '</a><a style=\"float:right\" href=\"\" index=\"' + i + '\">+/-</a></div></p>';
html += '<div class=\"vendorinfo\" id=\"sub' + i + '\"></div>';
}
$('#dOX').html(html);
$('.vendor a').toggle(function(e) {
var idx = $(this).attr('index');
var vendor = arrVendors[idx];
var html = '<table><tr><td>';
html += '<b>' + vendor.company + '</b><br />' + vendor.city + ', ' + vendor.state + '<br />';
html += vendor.phone1;
if (vendor.website) html += '<br /><a target=\"_blank\" href=\"http://' + vendor.website + '\">' + vendor.website + '</a>';
html += '<br /><br />';
html += '<i>' + vendor.description + '</i></td>';
html += '<td>';
if (vendor.photo) {
html += '<img src=\"http://managemymarket.com/imgproxy.aspx?maxh=200&maxw=200&img=' + vendor.photo + '&hires=1\" />';
} else {
html += '';
}
html += '</td>';
html += '</tr>';
html += '</table>';
$('#sub' + idx).html(html).show();
}, function(e) {
var idx = $(this).attr('index');
$('#sub' + idx).hide();
});
}
</script>
<!--Here is the link for the JSON feed:-->
<script type="text/javascript" src="http://www.managemymarket.com/api/json.aspx?return=ox&method=vendors&orgID=149"></script>
The script below will categorize the businesses but only lists the business names (not profile details i.e. picture, products, website etc).
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<div id="dOX"></div>
<script type="text/javascript">
function fn1(vendors) {
var types = {};
for (var i=0;i<vendors.length;i++) {
var v = vendors[i];
if (!types.hasOwnProperty(v.type)) {
types[v.type] = new Array();
}
types[v.type].push(v);
}
var html = '';
for (var t in types) {
html += '<h3>' + t + ' (' + types[t].length + ')</h3><ul>';
for (var j=0;j<types[t].length;j++) {
var v = types[t][j];
html += '<li>' + v.company + '</li>';
}
html += '</ul>';
}
$('body').append(html);
}
</script>
</head>
<body>
</body>
<script type="text/javascript" src="http://www.managemymarket.com/api/json.aspx?orgid=149&return=fn1&method=vendors"></script>
</html>
Does anyone have any suggestions on how I could combine these two scripts to display the company profiles within their respective category?
Any help would be greatly appreciated!
Brian
|