[jQuery] Client Data

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by Shadow121, Aug 25, 2010.

  1. Shadow121

    Shadow121 Member

    Messages:
    901
    Likes Received:
    0
    Trophy Points:
    16
    I'm making a live guest statistics thing for my site and I've recently gotten stuck with this one part of the code.

    Code:
            $.each(data,
            function(i,item){
                if(!$('tbody tr td a span span:contains("'+item.ip+'")').length ){
                    $('<tr class="datar">' + 
                    '<td><a href="#" onclick="return false;"><span><span>' + item.ip + '</span></span></a></td>' + 
                    '<td><a href=' + item.page + '" class="inlinelink"><span><span>' + item.page.substr(0,40) + '</span></span></a></td>' + 
                    '<td><a href="#" onclick="return false;"><span><span>' + item.browser + '</span></span></a></td>' +
                    '<td><a href="#" onclick="return false;"><span><span>' + item.os + '</span></span></a></td>' +
                    '<td><a href="#" onclick="return false;"><span><span>' + refreshes + '</span></span></a></td>' +
                    '</tr>').appendTo("#datatable tbody");
                }else{
                    $('tbody tr td a span span:contains("'+item.ip+'")')
    		      .next().html('<a href=' + item.page + '" class="inlinelink"><span><span>' + item.page.substr(0,40) + '</span></span></a>')
    		      .next().html('<a href="#" onclick="return false;"><span><span>' + item.browser + '</span></span></a>')
    		      .next().html('<a href="#" onclick="return false;"><span><span>' + item.os + '</span></span></a>')
    		      .next().html('<a href="#" onclick="return false;"><span><span>' + refreshes + '</span></span></a>');
                }
            });
    That should alter the table, although it doesn't.

    This is how the table is set-up:

    Code:
    <table cellpadding="0" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                                <th class="no"><a href="#" onclick="return false;"><span><span>IP Address</span></span></a></th>
                                <th class="no"><a href="#" onclick="return false;"><span><span>Viewing Page</span></span></a></th>
                                <th class="no"><a href="#" onclick="return false;"><span><span>Browser</span></span></a></th>
                                <th class="no"><a href="#" onclick="return false;"><span><span>Operating System</span></span></a></th>
                                <th class="no"><a href="#" onclick="return false;"><span><span>Page Views</span></span></a></th>
                            </tr>
                        </thead>
                        <tbody>
                            
                        </tbody>
                        <tfoot>
                            <tr class="first" id="noclients">
                                <td colspan="8" width="100%">
                                    <ul class="system_messages">
                                        <li class="white">There are no clients connected</li>
                                    </ul>
                                </td>
                            </tr>
                        </tfoot>
                    </table>
    It shows and hides the system message fine.

    Thanks in advance :D
     

Share This Page