I have a download counter on my website, here, that I am trying to get to work correctly.
The files for download are displayed in a 2 column table along with their respective download counts.
Here is the code that displays the table and files on the page:
Expand|Select|Wrap|Line Numbers
- <center>
- <table>
- <tr>
- <td>File Name</td>
- <td>Downloads</td>
- </tr>
- <?php
- foreach($files_array as $key=>$val)
- {
- echo '
- <tr>
- <td><a href="http://www.madtogger.co.uk/dlc_download.php?file='.urlencode($val).'">'.substr($val, 0, strpos($val, '.')).'</a></td>
- <td><span class="download-count">'.(int)$file_downloads[$val].'</span></td>
- </tr>';
- }
- ?>
- </table>
- </center>
Expand|Select|Wrap|Line Numbers
- $(document).ready(function(){
- /* This code is executed after the DOM has been completely loaded */
- $('tr').click(function(){
- var countSpan = $('.download-count',this);
- countSpan.text( parseInt(countSpan.text())+1);
- });
- });
I would really like to isolate the event so it only actually happens when cell1 where the actual filename is, is clicked.
I have tried changing the event to happen on the <TD> tag, while this still activates the download, the counter will not increase and I still have the same problem in clicking on cell2 increases the counter without downloading.
I hope all this makes some kind of sense and would appreciate any help at all.
Regards
K..,