Hi,
first off I would like to say that I posted this message over 24 hours ago and it said that I would have to await moderation but as yet nothing, so here goes again.
I have a download counter on my site that I am fiddling around with, see here:-
www.madtogger.co.uk/page/software
The counter is printed to the screen using the code below:-
- <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>
The counter is activated using the jQuery code below:-
- $(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);
- });
- });
As you can see, the click function activates when the user clicks on the filename that they want to download as it is contained within the <TR> tag and this then updates the counter display.
That all works fine but the glitch I am trying to solve is that if a user just clicks on cell2 of the table row the counter also increases even though a download has not been started.
What I am trying to achieve is that a user can only click the filename to cause the counter to increase and that no action is taken when a click is made anywhere else on the row.
Any help would be appreciated.
Regards..,
K