How to change this or achive this?

krueke

New Member
OK so what I'm trying to do here is that I want a download counter which will count downloads in real time and output the value in real time without needing the user to clear their cache or refresh the page. Now I am able to achieve this using a little bit of JavaScript (this is being used to update in real time) combined with MySQL and PHP. But the problem is that in order for me to get it to output the value in real-time, I mean when a user clicks on this "button" I have to create a span tag and contain it inside the anchor tag which contains the button/link I'm tracking.To help you better understand, here are is my HTML and JavaScript.\[code\]<?php foreach($files_array as $key=>$val) { echo '<a class="btn btn-primary btn-large" href="http://stackoverflow.com/questions/15605937/download.php?file='.urlencode($val).'"><span class="download-text">Download </span></a><span class="download-count" title="Times Downloaded">'.(int)$file_downloads[$val].'</span> '; }?>\[/code\]And here is the JavaScript\[code\]$(document).ready(function(){/* This code is executed after the DOM has been completely loaded */$('#download-button a').click(function(){ var countSpan = $('.download-count',this); countSpan.text( parseInt(countSpan.text())+1);}); });\[/code\]I want to be able to not contain the span tag for the counter inside the tag but outside it.Thanks in advance :)
 
Back
Top