Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously?
| From: | Negin Nickparsa | Date: | Sun, 14 Oct 2012 11:41:45 +0000 |
| Subject: | Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-319448@lists.php.net to get a copy of this message | ||
I have a table,which has a field counting the downloaded files,so with php
I can return the value:
<span class="num" id="<?php echo $id;?>">Downloaded:<?php echo
$downloadcount;?></span>
when clicking the button,it will download the file:
<input type = "button" value="Download" class="button"
id="<?php echo
$id; ?>" name="dl" onclick="window.location.href='<?php echo
$track;?>'">
I wanted to refresh the download count when clicking the button first is it
possible?because I think by using onclick in the span section I can't have
an onclick event in jquery but if I will assume that it is possible then
how to store it in php?so I can update the table?
I wrote something which is wrong:
$(function() {
$(".button").click(function(){
var clicks = 0;
var theID = $('.num').attr('id');
clicks++;
$(theID).html("Downloded:"+clicks);
});
});
in php section I have a while loop that will return each row like this:
while($row=mysql_fetch_array($sql))
{
$id=$row['ID'];
//some code
}
here is my demo if you would like to see the whole enter james in textbox:
http://parsa-web.goodluckwith.us/index.php