Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,121
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    The obvious answer is to change the ASP.NET code to allow you to specify a sort order. Much easier solution than mucking in the JS code.

    All the ASP.NET code has to do is change the SQL query's ORDER BY clause to match your request.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Pedant,

    I'm going back to the company that provides the feed and see if they are willing to change the SQL statement.

    Thanks
    Brian


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •